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
-
Hi Matt,
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
0 -
2020-12-15-092724Yuri --Thank you for the suggestion.I will check into this.I may do a combination of the two and read the file into an array that holds the lines so that I can access the lines randomly.Thanks.-- Matt
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions