Click to See Complete Forum and Search --> : Random Access Files
Dmanley
August 9th, 2001, 09:21 AM
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?
Andrew R.
August 9th, 2001, 05:32 PM
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
Dmanley
August 10th, 2001, 10:17 AM
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.