Problems with FileRead at end of the file
Once again...
I read a textfile with $\r$\n at the end of every line in a loop.
When i get to the end, the last string isn't read. The string is empty "" because i got to the end of the file.
So my idea was to get the position of the last read and then read from there to the end of the file to avoid the "" string, but it doesn't work. Heres the code maybe you have an idea...
$9 is the filehandle
FileSeek $9 0 "END" $R8
FileSeek $9 0
unDOloop:
FileSeek $9 0 "CUR" $R9 ;get file position
FileRead $9 $2 ;Read string from file
StrCmp $2 "" end ;If end of file is reached, exit procedure
StrCpy $R0 $2 3 ;Get first letters and do function accordingly
StrCmp $R0 $R1 "" unDOloop ;if not type of change stated in $R1, seek further
call un.restore_changes ;if this is the right thing, restore values (string already in $2)
goto unDOloop ;and loop till end of the file
end:
;MessageBox MB_OK|MB_TOPMOST|MB_ICONINFORMATION "Last Fileposition : $R9$\r$\nLenght of file : $R8$\r$\nString is $2" 0 0
FileSeek $9 $R9 ;we've read past the end of the file, so get back to start of string
IntOp $R8 $R8 - $R9 ;get length till EOF-1
Intop $R8 $R8 - 1
FileRead $9 $2 $R8 ;read last string in file
StrCmp $2 "" exit ;If still end of file, exit procedure
StrCpy $R0 $2 3 ;Get first letters and do function accordingly
StrCmp $R0 $R1 "" exit ;if not type of change stated in $R1, exit
call un.restore_changes ;restore values (string already in $2)
exit:
KIM