07-28-2003, 06:41 AM
07-28-2003, 11:49 AM
Packed length?
dim record as recordtype
Recordnum=lof(1)\len(record)
dim record as recordtype
Recordnum=lof(1)\len(record)
07-29-2003, 04:20 AM
I don't understand that. What I mean is that when I open a random file I have to specify how large it is, depending on the data. How do I figure the packed length and length of each data.
07-29-2003, 10:45 AM
I have just answered your question. That is, assuming I understand it. ;*)
Okay let's says you have a random file that you already have opened...
You certainly would want to use types here.
Say you have a type:
now you want to dimension a record as that type...
Lof(1) gets the length of file in bytes so you have to get the length of the record to get the number of records...
so LOF(1) returns the (L)ength (O)f (F)ile.
;*)
Okay let's says you have a random file that you already have opened...
You certainly would want to use types here.
Say you have a type:
Code:
type recordtype
Nam as string * 50
age as integer
sex as string *1
end type
now you want to dimension a record as that type...
Code:
Dim record as recordtype
Lof(1) gets the length of file in bytes so you have to get the length of the record to get the number of records...
Code:
Numrec=Lof(1)\Len(record)
so LOF(1) returns the (L)ength (O)f (F)ile.
;*)
07-29-2003, 11:02 AM
The only way I know how to create a random file is by this:
An example but I don't know how they figured out the length of each data.
Code:
FILEOPEN:
OPEN "R", #1 "cust.dat", 128
FIELD #1, 4 AS custnum$, 30 AS custname$, 30 AS custaddr1$, 20 AS custcity$. 2 AS custcity, 2 AS custst$, 4 AS custst$, 4 AS custzip$, 2 AS custtype$, 8 AS custbal$
RETURN
An example but I don't know how they figured out the length of each data.
07-29-2003, 11:09 AM
Geez, that don't even look like QBasic!
I suggest you read the QBasic help more thoroughly (try clicking on the "QBOHO" link above, because it looks suspiciously like you're barking up the wrong tree
I suggest you read the QBasic help more thoroughly (try clicking on the "QBOHO" link above, because it looks suspiciously like you're barking up the wrong tree
07-29-2003, 11:18 AM
DValan: That's the old way of doing random access files. Types simplifies things. ;*)
07-29-2003, 11:19 AM
Hmm it's copied right out of my Qbasic teach yourself book. It was written like 10 years ago though.