Here you go, Sasuke. This should be the original code that LBFN posted for me to use.
Score = 0
DIM HighScore(9)
DIM Name$(9)
global ScrWid : ScrWid = screen width() : global ScrHgt : ScrHgt = screen height()
if file exist("test.txt") = 0
gosub SetupHighScores
else
gosub LoadHighScores
endif
KeyDelay = timer() + 100
repeat
gosub ShowHighScores
gosub GetInput
ink rgb(255,255,255),0 : ` white
center text 100,10,"SCORE: " + str$(score)
text 100,ScrHgt - 120,"Press '1' to increase score by 2000."
text 100,ScrHgt - 100,"Press 'S' to save the HighScores."
text 100,ScrHgt - 80,"Press 'A' to add the HighScore to the table."
text 100,ScrHgt - 60,"Press [Spacebar] to quit."
until spacekey() = 1
end
GetInput:
` gets a keypress from the user
if scancode() > 0 and timer() > KeyDelay : ` slow it down so it doesn't update too fast
I$ = upper$(INKEY$()) : ` use Upper$() to make sure the input is always uppercase
select i$
case "1"
inc SCORE,2000
endcase
case "S"
cls
ink rgb(0,0,255),0
center text ScrWid * .5,ScrHgt * .5,"Saving file....."
sync
gosub SaveHighScores
wait 1200
cls
center text ScrWid * .5,ScrHgt * .5,"High Score table saved."
sync
wait 1500
endcase
case "A"
gosub OverWriteHighScores
endcase
endselect
KeyDelay = timer() + 100 : ` update the key delay
endif
return
ShowHighScores:
cls : ` clear the screen
ink rgb(255,255,0),0 : ` yellow
for s = 0 to 9 : ` print out the different names and high scores
text 100,(s * 20) + 50,Name$(s)
text 200,(s * 20) + 50,str$(HighScore(s))
next s
return
SaveHighScores:
` check to see if there is an existing file - if so, delete it
if file exist("test.txt") = 1 then delete file "test.txt"
Open to Write 1,"test.txt"
For N = 0 To 9
Write word 1,HighScore(N)
Write String 1,Name$(N)
Next N
Close File 1
return
LoadHighScores:
repeat
text 100,100,"okay after Loading/Setting up the high scores."
text 100,120,"click the left mouse button to continue."
until mouseclick() = 1
if file exist("test.txt") = 1
open to read 1,"test.txt"
for n = 0 to 9
read word 1,HighScore(n)
read string 1,Name$(n)
next n
close file 1
endif
repeat
text 100,100,"okay after Loading/Setting up the high scores."
text 100,120,"click the left mouse button to continue."
until mouseclick() = 1
return
OverwriteHighScores:
cls
ink rgb(255,255,255),0
center text ScrWid * .5,ScrHgt * .5,"Updating high score table."
sync
wait 1200
pos = -1
for hs = 9 to 0 step -1
if score > HighScore(hs) then pos = hs
next hs
if pos >= 0 and pos < 9
` move the HighScores that are lower than score down by one
for hs = 8 to pos step -1
Name$(hs + 1) = Name$(hs)
HighScore(hs + 1) = HighScore(hs)
next hs
endif
if pos = 9 then HighScore(9) = score
if pos >= 0
text 10,ScrHgt - 200,"Congratulations! Your score is one of the top ten!" : sync
set cursor 10,ScrHgt - 180
INPUT "Enter your name: ",Name$(pos)
HighScore(pos) = score
endif
return
SetupHighScores:
` gets here if there is no saved file and puts values into the arrays
restore HighScoreData
repeat
text 100,100,"okay after Loading/Setting up the high scores."
text 100,120,"click the left mouse button to continue."
until mouseclick() = 1
for s = 0 to 9
read HighScore(s),Name$(s)
next s
return
HighScoreData:
` score, name$
data 1990,"Bob1",1991,"Bob2",1992,"Bob3",1993,"Bob4",1994,"Bob5"
data 1995,"Bob6",1996,"Bob7",1997,"Bob8",1998,"Bob9",1999,"Bobx"