FSEEK() is actually moving the pointer. If I do the following I get the expected results except that BOF() doesn’t return True even before I move through the file.
Using FGETS(<fd>,0,1) appears to correctly return the current position:
open database southwind use customers copy to xxx.txt type csv xxx=fopen("xxx.txt") ? xxx ? bof() ? fseek(xxx,0,1) ? fgets(xxx) ? fseek(xxx,0,1) ? fseek(xxx,0,0) ? fseek(xxx,0,1)
The FEOF() flag only gets set/reset after a read operation. As Dave says, the fseek(FileHandle,0,0) is returning you to the start of the file, it’s just that having been set, FEOF() won’t be unset until you do another read operation. Try something like this:
FileHandle = FOPEN(Lianja.Get("Gamesheet.GSHeader.txtGamesheet").text) Do While .T. cGetline = fgets(FileHandle) If FEOF(FileHandle) exit else // process ... endif ENDDO fseek(FileHandle,0,0) // Return to start of file Do While .T. cGetline = fgets(FileHandle) If FEOF(FileHandle) exit else // process ... endif ENDDO