Archive: A question regarding FileSeek


A question regarding FileSeek
I looked through the documentation for FileSeek. It looks like it sets file pointer to an offset from the start or end of the file. I wonder if the FileSeek can set file pointer to, for example, the second line of the file?


Do N FileReads (FileRead reads up to and including the next \r\n or \n while also moving the pointer).

Stu


Originally posted by Afrow UK
Do N FileReads (FileRead reads up to and including the next \r\n or \n while also moving the pointer).

Stu
I am sorry but I don't understand what is "N FileReads". Could you be more clear? Thanks a lot.

N = an arbitrary number. If you want to read the 2nd line, use 2 FileRead instructions.

Stu


Originally posted by Afrow UK
N = an arbitrary number. If you want to read the 2nd line, use 2 FileRead instructions.

Stu
Thanks for your explainations. I have another question regarding FileSeek. If I use FileSeek like,

FileSeek $0 0
FileRead $0 $1

Then $1 is only first line of the file. How can I make sure I read the whole content of the file?

You have two options:
1. Use FileReadByte in a loop until the error flag is set (will read the byte as an integer so you need to use IntFmt to convert it to a character).
2. Use ReadFile API via the System plug-in. The handle returned from FileOpen should work.

In both cases, you are limited to 1024 characters (or 8129 for the special build) so reading the entire contents of the file is not a good idea.

Also why do a FileSeek? When you open a file, the pointer will be at the beginning of the file anyway.

Stu