Searching a String in a Textfile

SOVSOV Member Posts: 6
Hi there,

I am currently trying to search for a certain String in a Textfile. I never did that before since I am pretty new to Navision and my first idea was to read the File-Variable in a BigText-Variable and search inside of this BigText-Variable for the different positions of the string I am looking for. But this won't work because the STRPOS-function can't be used in combination with a BigText-Variable as it seems.
I searched this forum but could not find a fitting solution to my problem.
Do you have any suggestions on how to search for a certain String in a Textfile? As easy as possible ;-)

Thanks in advance,
SOV

Answers

  • SOVSOV Member Posts: 6
    Oh and I need to check the Textfile line per line. I think this is achieved using:

    FileVariable.TEXTMODE(TRUE);

    Is that correct?
  • DenSterDenSter Member Posts: 8,305
    I don't know how to do this for a whole file, but if you want to do it line by line, then you can read a line into a tect variable (with a limit of 1024 characters) and evaluate the textvariable. I believe the command is MyFile.READTEXT.
  • SOVSOV Member Posts: 6
    Thanks for your answer.

    I now tried it like this:

    FileVariable.READ(Line_Variable);

    since "FileVariable.READTEXT", as you suggested, unfortunately didn't work.

    When I want to find e.g. the substring "codeunit" in a text-variable, then I thought one would do that like this:

    IF LineVariable = '*@codeunit*' THEN ...

    But that won't work. :-(


    Could anyone tell me what would be the correct way to achieve this last point?

    Cheers,
    SOV
  • SOVSOV Member Posts: 6
    Think I got it. At least I have found some new things to try.
    Thanks for your help.

    SOV
Sign In or Register to comment.