Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / File End() problems... Need help. :)

Author
Message
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 16th Jan 2011 10:56 Edited at: 16th Jan 2011 10:58
So I have this code to load in a file. But it seems to keep going even after the file has ended...
Is there a known problem with File End(f), or can you see any mistakes in my code?

I have tried using WHILE FILE END(f) <> 1, and have also tried using a REPEAT - UNTIL FILE END(f) loop instead.
Nothing seems to work... As far as I can tell from debugging it just keeps going...

Any help is greatly appreciated...



IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Jan 2011 14:04
End of file is not detected on successful reads, as at that point you haven't encountered the end-of-file.

It's when you attempt to read and there's nothing left to read the EOF is flagged.

Here's the form I use (other forms are just as valid):


Basic assumption: That reading the string successfully, means that there is valid data following it. You should probably check that you got everything you needed anyway - a quick check is that EOF should NOT be set when you are at the bottom of the loop, and if it is, you have a problem.

enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 16th Jan 2011 18:30 Edited at: 16th Jan 2011 18:36
It would be like this though, right?


As far as I can tell in the help file it returns 1 when it is the EOF.

EDIT: Yes, that was it. Thanks alot IanM.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Jan 2011 23:13
Oops, yes, my mistake. You got it anyway

Login to post a reply

Server time is: 2026-07-18 02:08:54
Your offset time is: 2026-07-18 02:08:54