Home Image-Pro Automation (Macros, Apps, Reports)
Options

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

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

Answers

  • Options
    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

  • Options
    2020-12-15-092724

    Yuri --

    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

Sign In or Register to comment.