|
-
August 9th, 2001, 09:21 AM
#1
Random Access Files
I have a file I'm trying to access randomly. the only problem is that I have a record header at the beginning that is not the same length as the other records. Is there a way when writing to this file to tell it to write to fifth file but add in the offset of 64 bytes to account for the record header?
-
August 9th, 2001, 05:32 PM
#2
Re: Random Access Files
As I understand you have file of records (with static size) and this file also has a header.
So:
You know the size of your header = A
You know the size of each record = B
Now to read/write any record R you do:
' open file
Open "C"\MyFile.dat" for binary Access Read Write lock Read Write as #1
'...
' set position
seek #1, (A + (B * R))
' read by get() or Write by Put() functions
-
August 10th, 2001, 10:17 AM
#3
Re: Random Access Files
Thanks for the help. That did the trick. I can't believe I haven't heard or read of this yet. I've been trying to figure this out for days and the answer is so simple.
Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|