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.

Newcomers DBPro Corner / File Problems - DBP

Author
Message
timmayj
18
Years of Service
User Offline
Joined: 10th May 2006
Location:
Posted: 1st Jun 2006 06:18
My goal here is to write the value (integer) of highscore to a file, so that it may be loaded the next time my program is executed. My code seems like it should work; it creates a file if it does not already exist, but nomatter what was in highscore, it reads a 1 from the file. Any ideas?
Thanks in advance.

Quote: "
`Scores/Files
if FILE EXIST("highscore.dat")
OPEN TO READ 1,"highscore.dat"
READ LONG 1,highscore
CLOSE FILE 1
else
MAKE FILE "highscore.dat"
OPEN TO WRITE 1,"highscore.dat"
WRITE LONG 1,highscore
CLOSE FILE 1
...
...
...
if score>highscore
highscore=score
DELETE FILE "highscore.dat"
MAKE FILE "highscore.dat"
OPEN TO WRITE 1,"highscore.dat"
WRITE LONG 1,highscore
CLOSE FILE 1
set cursor 0,10
set text size 100
print "SCORE=",score
print "NEW HIGH SCORE!"
set cursor 0,220
print "G A M E O V E R"
endif
"


http://timmayj.cjb.net/
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Jun 2006 15:51
I don't know what's happening to populate the score value but one thing you can do is remove the "MAKE FILE" line. It's not needed and may just be adding confusion.



Login to post a reply

Server time is: 2024-09-24 23:32:02
Your offset time is: 2024-09-24 23:32:02