Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Open" Problem
#1
Here's a portion of code for a game I'm making. I keep getting an error "input past end of file"

Code:
LOAD:
PRINT "not done yet"
CHOICE = 0
OPEN "fballsav.txt" FOR INPUT AS #1
WHILE NOT EOF(1)
INPUT #1, qb, kicker, seasons, TOTALWON, TOTALLOST, WON, LOST, NAME$, TRAIN
WEND
CLOSE
RETURN

SAVE:
PRINT "NOT DONE YET"
CHOICE = 0
OPEN "fballsav.txt" FOR OUTPUT AS #1
PRINT #1, qb, kicker, seasons, TOTALWON, TOTALLOST, WON, LOST, NAME$, TRAIN
CLOSE
RETURN
Not yet Snake! It's not over yet!
Reply
#2
{DOUBLE POST}(SORRY)
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#3
The info is not there for you to load, if you have a txt file with not as many numbers as there are there, it will not work.
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#4
That doesn't seem to be the case, because I have 9 variables and 9 values in my save file. Here's what it looks like:

50 50 0 0 0 0 0 name 0
Not yet Snake! It's not over yet!
Reply
#5
I think It's the loop.

try:
DO
IF EOF(1) = -1 THEN EXIT DO
INPUT #1, blah blah blah
LOOP

That will work as long as the txt file is correct which you said ot was.
i]"But...it was so beautifully done"[/i]
Reply
#6
NAME is a restricted variable name.

#1. Try using something different, like playername$
#2. Make sure the playername$ doesn't contain commas, semicolons or spaces.

Just some hints though, because I'm not able to test it atm Smile
Reply
#7
learn binary =P
Reply
#8
i think your problem is your while loop. It loops, then when it reaches the end of file it loops once more. Unfortunately, it has nothing else to read, so you got your error. use a do-loop, or use LOF() to find the length of the file, then run a for...next loop.
Jumping Jahoolipers!
Reply
#9
WHILE NOT EOF should work fine.
Reply
#10
[syntax="qbasic"]OPEN "fballsav.txt" FOR INPUT AS #1
WHILE NOT EOF(1)
INPUT #1, qb, kicker, seasons, TOTALWON, TOTALLOST, WON, LOST, NAME$, TRAIN
WEND
CLOSE[/syntax]

I think your problem his here as well, but not necessarily with the WHILE loop. Since the "EOF" statement is at the top, it should evaluate that everytime it restarts the loop-- so if it reaches the end of the file, it should simply stop. I think your problem somewhere within the input statement:

[syntax="qbasic"]INPUT #1, qb, kicker, seasons, TOTALWON, TOTALLOST, WON, LOST, NAME$, TRAIN[/syntax]

What may be happening is you might have a file that looks like this:

Code:
50 50 0 0 0 0 0 name 0

With an extra blank line at the end of the file. If there is one, delete it.

If that doesn't work, try adding commas so your file looks like this:

Code:
50,50,0,0,0,0,0,"name",0

You'll still get the same result, but it should be easier to work with.

Good luck!

--j_k
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)