How to do 'positioning' on a text file in read mode?
Posted on 2006-05-15
1. we can read a text file 'sequentially' , 1 line (1 record) at a time, with the following VB code:
dim ch_read as integer ' file pointer as my reading channel
dim a_record as string ' one line of the record for various length as string
open "text_file.txt" for input as #file_nbr
Line Input #ch_read, a_record
... so you read (Forward) a few line of this string into a_record
2. Questions: how to 'rewind' the read N records, so I can read forward again?
I used to see 'rewind N' statment in some old basic or f77 language a while ago.
there is a seek() statement in VB, but it only seeking through number of bytes
from beginning, and I need to keep track it. alghough this is not totally impossible
(for example, the length of each record + 2 (LFCR), or somthing like this.)
3. I am looking for the 'rewind N' record statement in VB6
also, can we do 'BOF' --- positoin the next reading position at 'begging of the file'
or 'EOF' end of file, so we can do 'append' statement.
I hope someone can help me on this simple and useful mechanism to move around a 'file'
with one record at a time. -- forward, and backward.