Archive: Start FileRead at a given line number


Start FileRead at a given line number
Hi all,

I use FileRead to read a file (txt) line by line, but sometimes I have to write to the file at the same time. For this, I close the file, do the write and then reopen the file. At this point I have the line number and I'd like to start FileRead from that line, and not from the very beginning.

I thought FileSeek is able to do that but I was wrong (or was I?)


You could add up the number of characters you have processed so far by using StrLen on each line but this would not work if lines were over 1024 characters.

Try the Text Functions header (section E.2 in the documentation).

Stu


Thanks for the fast answer (as always).

Yes I know there would be several workarounds but I hoped that there was an easier solution. Fortunately reading those lines two (or more) times does not do any harm but the script is not as pretty as it could be :)

Maybe creating a copy of that txt file in the Temp dir is the easiest way - opening that for reading and the original one for writing, with deleting the temporary txt file at the end.


Yes that's how you should do it anyway.

Stu