Sorry, there was a small typo in the original. Seeing as you asked nicely, here's a complete example that I've commented. As long as you know how to use a function, you should have no problems understanding it.
` Get the hiscore
Hiscore=GetHiscore()
` Get a new score
print "The hiscore is "; Hiscore
input "Enter new score : ", NewScore
` If a new hiscore, update the hiscore
if NewScore > HiScore
print "Whoohoo - a new hiscore"
SaveHiscore( NewScore )
else
print "Sorry, you didn't beat the hiscore"
endif
` All done now
wait key
end
function GetHiscore()
if file exist("hiscore.dat")
open to read 1, "hiscore.dat" : ` Open the hiscore file
read file 1, value : ` read in the hiscore
close file 1 : ` close the hiscore file
else
value=0 : ` when the file does not exist, pass back a zero
endif
endfunction value
function SaveHiscore(Score)
if file exist("hiscore.dat") then delete file "hiscore.dat" : ` remove the hiscore file
open to write 1, "hiscore.dat" : ` create a new one
write file 1, Score : ` write the score to the file
close file 1 : ` close the hiscore file
endfunction