function SaveScore(playerName as string, score as dword)
if file exist("highscore.dat") then delete file "highscore.dat"
fileId = 1 ` Set to a free file Id if you already have a file 1 open
open to read fileId, "highscore.dat"
write string fileId, playerScore
write long fileId, score
close file fileId
endfunction
function LoadScore()
rem Assumes TopScore and TopPlayerName are globals. You can of course do this in other ways too.
if file exist("highscore.dat")
fileId = 1
open to read fileId, "highscore.dat"
rem The syntax is quite different here; the built-in file reading functions
rem are about the only ones in DBPro that use references when returning data
rem instead of returning copies.
read string fileId, TopPlayerName
read long fileId, TopScore
close datafile
else
rem No nighscore file exists; set generic values
TopPlayerName = "N/A"
TopScore = 0
endif
endfunction
"Why do programmers get Halloween and Christmas mixed up?" Because Oct(31) = Dec(25)