|
Post by adh on Jun 25, 2004 17:00:01 GMT -5
I have used the the openreadfile,openwritefile to read to and write from a file. But my question is if i can read and write in a specific line number of that archive, for example, I want to read fron a text file the line number 5, and only that line of the file. thanks.
|
|
|
Post by AHBanen on Jun 25, 2004 18:40:24 GMT -5
I haven't time to test it out myself first, but in general for random access I would start with using Seek( int, int) to move the file pointer to a specific position. Seek( nOffset, dwFrom ) Parameters: nOffset The offset from the starting point given by dwFrom. dwFrom The starting point (FILE_BEGIN, FILE_CURRENT, or FILE_END).
If not predefined in Basic4GL use these values: FILE_BEGIN = 0 FILE_CURRENT = 1 FILE_END = 2
However your problem states you want to read a specific line from a file. But because you cannot know the length of each line in advance (unless you made a list with offsets to each line first: an index) you cannot read a specific line unless you use ReadLine to read all lines one by one until you get to the right one ( See Programmer's Guide "File reading routines" from the Help Menu in Basic4GL.exe
Have fun programming File I/O in Basic4GL!
André
|
|