JohnChen
5th May 2011 21:21 UTC
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?
Afrow UK
5th May 2011 21:25 UTC
Do N FileReads (FileRead reads up to and including the next \r\n or \n while also moving the pointer).
Stu
JohnChen
5th May 2011 21:39 UTC
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.
Afrow UK
5th May 2011 22:30 UTC
N = an arbitrary number. If you want to read the 2nd line, use 2 FileRead instructions.
Stu
JohnChen
6th May 2011 16:46 UTC
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?
Afrow UK
6th May 2011 16:59 UTC
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