Error Message EOF

Blitz3D Forums/Blitz3D Beginners Area/Error Message EOF

Merrie(Posted 2006) [#1]
I am brand new to Blitz 3D and am having a great time with it. I am also a beginning programmer, so this seems to be working out fine for me.

I also purchased the Blitz 3D book and am going through it and several of the website tutorials.

I am working through the Battle tutorial I found on the website and put in all of Chapter 1 details which deals with terrain and camera.

At this stage I figured I could view it so tried to and Im getting Expected End-of-file, would someone be kind enough to give me a hint of what the program is looking for?

Thank you!


Sledge(Posted 2006) [#2]
If you've no file access going on then it may be a typo in your code - I got something similar just the other week. Compiling is so fast that I test every few lines (or at least every block/sub/func) so I just fixed the last dumb mistake I made, saying "fancy that", and moved on without bothering to make a note of the details. Anyway, post the problematic code and we'll take a look.


D4NM4N(Posted 2006) [#3]
if you post the file access code we can better see the problem.

Unexpected end of file could be because you are attempting to read past the end of the file. For example if there are 100 items in your file and your code is trying to read 101 items from it youve got a problem

try adding an eof evaluator to the end of the loop, ie:
file=readfile("name.dat")
repeat
    whatever = read{line/byte/int/float} (file)
until eof(file)

this will repeat until the end of data.

Alternatively if using a for next..
for ....
   if not eof(file)
      whatever= readline(file)
   else
      exit
   endif
next



Merrie(Posted 2006) [#4]
Let me review the code first and if I still cant' find it I'll post it. Thanks for the suggestions!


Adam Novagen(Posted 2006) [#5]
Hey, D-grafix, one problem with using Repeat...Until loops to read file contents is that Repeat...Untils always iterate at least once before exiting. This isn't a problem if the file has anything in it, but if it's a blank file, then a Repeat...Until will generate a single byte/line of data that doesn't exist. You For...Next loop is great, but probably the most compact way to do this is to use a While...Wend loop like this:
While Not Eof(file)
...;all da crap you wanna do
Wend
In this case, if the file is empty, the loop will exit immediately. Like I said, this usually isn't a problem, but if you need absolute precision, then the Repeat...Until just doesn't work out.


IPete2(Posted 2006) [#6]
Merrie,

You can catch me on Skype at petermcaddock or msn on ipete2@... if you want some more help.

IPete2.


D4NM4N(Posted 2006) [#7]
Good point ADAM :)

hehe youre right. i normally use rep until to be able to quit when reading scripts ie (altho exit works just as well):
if file
 repeat
   if eof (file) exit
   read...
   if something wrong scripterror$="errmsg"
 until eof(file) or scripterror<>""



i know, i know messy!(bad habbits die hard), while wend is better... I really must get into the habit of using while loops.

Right... Tonight ill go to sleep dreaming:

while not awake
print "WHILEWENDWHILEWEND"
wend


Adam Novagen(Posted 2007) [#8]
LOL D-Grafix... XD


Sir Gak(Posted 2007) [#9]
Adam is right about the Repeat-Until and While-Wend. I agree that While-Wend is best for checking for EOF in case you have a blank file situation. However, in other loop situations, say, like displaying a background graphics screen until you get keyboard/mouse input, then a Repeat-Until loop is best. You get at least one screen generated before going to your loop awaiting further direction from the user's input.


Adam Novagen(Posted 2007) [#10]
Adam is right about...

It's not "Adam," it's "ADAM"!!! ADAM!!! AAAAAAAGH!!!!!

Sir Gak has a point about that graphics rendering Repeat...Until thing, though.


Sir Gak(Posted 2007) [#11]
Thanks, ADAM.

It's not "Adam," it's "ADAM"!!! ADAM!!! AAAAAAAGH!!!!!


Shouldn't that be spelled :"Aarrgghh", though?


Adam Novagen(Posted 2007) [#12]
Depends on the sound you're trying to represent. I mean, "Aarrgghh" is fine if you're symbolizing, say, a very snarl-like scream... You know, teeth bared and all that crap... But "AAAAAAAGH" is better if you're representing some kind of medium-pitch lunatic scream... And most people generally acknowledge me as a lunatic... A cool lunatic, but a lunatic nonetheless... ^_^