SEEK INSTRUCTION . . .
2020-12-14-185411
All --
I am working with a ASCII TEXT LOG FILE that contains hundreds (sometimes thousands) of entries.
I would like to be able to use the SEEK INSTRUCTION to randomly access the information on LINE X of the LOG FILE.
I believe that the information in the MACRO SCRIPTING HELP FILE that says
SubMain
FileOpen 1, "XXX", OpenMode.Input
L = LineInput(1)
Seek 1, 1 ' rewind to start of file
Input 1, A
FileClose 1
Debug.Print A
EndSub
FileOpen 1, "XXX", OpenMode.Input
L = LineInput(1)
Seek 1, 1 ' rewind to start of file
Input 1, A
FileClose 1
Debug.Print A
EndSub
should allow me to SEEK to the LINE of the LOG FILE that I want to read.
This does not seem to work.
after googling, it seems that the OpenMode maybe should be
OpenMode.Random
but this seems to generate an error when I use this.
When I use
OpenMode.Input
the CODE works but the SEEK moves the pointer by character rather than by LINE.
Is there a solution for this that will avoid doing an INPUT on each line before the LINE I actually want?
Thanks.
-- Matt
0
Answers
Depending on the file format you may use specific file readers (INI, XML, JSON,...).
If you just want to parse a text file, then the easiest way would be to read all file to a string (File.ReadAllText) and then use System.String functions to analyze it.
Yuri