Qbasicnews.com

Full Version: READ data from another file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have a program that is using an extraordinary amount of DATA entries. So many, in fact, that it is not letting me post them all in a single file (module?). All of this data is filling a single array with three "parts." i.e. tileset(x,y,z)


Is there a way to do a READ...DATA in which the primary program pulls the data from another file and applies it to the array? Is there another function that is more efficient?
Yeah

Open "Filename.dat" for input as #1
Binary mode would be more suitable.

Code:
TYPE valtype
   val(1 to 3) AS INTEGER
END TYPE

DIM DATA(1 to 1000) AS valtype

this would be the basic structure of the records. Then you can read and write to the file quite easily. Just look up the binary file format and some examples of it.
Beware! That will only work in PDS and VBDOS.
Quote:Beware! That will only work in PDS and VBDOS.

meh Nathans just scaring you =P. This structure(TYPE) will work in lower versions as well :rotfl:

Code:
TYPE valtype
   val1 AS INTEGER
   val2 AS INTEGER
   val3 AS INTEGER
END TYPE

DIM DATA(1 to 1000) AS valtype
Quote:
na_th_an Wrote:Beware! That will only work in PDS and VBDOS.

meh Nathans just scaring you =P. This structure(TYPE) will work in lower versions as well :rotfl:

Code:
TYPE valtype
   val1 AS INTEGER
   val2 AS INTEGER
   val3 AS INTEGER
END TYPE

DIM DATA(1 to 1000) AS valtype

Of course it works in QB45, but you can't use arrays inside.
Code:
TYPE valtype
   val(1 to 3) AS INTEGER
END TYPE

DIM DATA(1 to 1000) AS valtype

Code:
TYPE valtype
   val1 AS INTEGER
   val2 AS INTEGER
   val3 AS INTEGER
END TYPE

DIM DATA(1 to 1000) AS valtype

Ahem...Nathan, the two structures are different =P. The first one works only in PDS and VBDOS while the second one works in qb v4.5 and others Wink
Well, I complained when you posted only the first one.
omg. Wink Actually TBBQ, if you think that's different, then this is as well:

Code:
TYPE BLABLA
A AS INTEGER
END TYPE
Code:
TYPE BLABLA
B AS INTEGER
END TYPE

Big Grin
Quote:omg. Wink Actually TBBQ, if you think that's different, then this is as well:

Code:
TYPE BLABLA
A AS INTEGER
END TYPE
Code:
TYPE BLABLA
B AS INTEGER
END TYPE

Big Grin

Neo you have lost your brains or eyes. *Look* at both of my 'TYPEs'. One clearly uses an array inside the type which is supported by Qb 7.1 and VBDOS. While the second one doesnt use an array which is supported even by the older versions of qb.
Pages: 1 2