Hi
Is there some function that gets to go forward and back in a file?
thank you in advance
Printable View
Hi
Is there some function that gets to go forward and back in a file?
thank you in advance
Why dont you just read the entire file into memory and then do whatever you want to it.
Hi
The file is very great
The file pointer is the position in the file where the next read (or write) will take place. The SEEK statment changes the file pointer.
If all the records are the same size, use RANDOM access and SEEK a particular record.
Code:'Random access file -- each record is the same size.
Dim MyRecord as string * 40
' Open file in random-file mode.
Open "TESTFILE" For Random As #1 Len = Len(MyRecord)
MaxSize = LOF(1) \ Len(MyRecord) ' Get number of records in file.
' read in backwards
For RecordNumber = MaxSize To 1 Step - 1
Seek #1, RecordNumber
Get #1, , MyRecord
Next RecordNumber
Close #1
'Reading a text file
Open "TESTFILE" For Input As #1
MaxSize = LOF(1) ' Get size of file in bytes.
' this code reads the file backwards
For NextChar = MaxSize To 1 Step -1
Seek #1, NextChar ' Set position.
MyChar = Input(1, #1) ' Read character.
Next NextChar
Close #1 ' Close file.
Hi
thanks, but how do I read backward, I read 20 bytes and want backward 5 bytes ?
thanks