Hello!
I'm working on a simple arcade game in App Game Kit. I've been struggling with saving and loading data from txt file for over a week.
Here's my code:
#constant HIGHSCORE_FILE$ = "data.txt"
Function Read_High_Score()
if not GetFileExists(HIGHSCORE_FILE$) then NewHighscoreFile()
local filein as integer
filein = OpenToRead(HIGHSCORE_FILE$)
highscore = val(ReadLine(filein))
CloseFile(filein)
Endfunction
Function Write_High_Score()
Local fileout as Integer
highscore = score
fileout = OpenToWrite(HIGHSCORE_FILE$,0)
WriteLine(fileout, str(highscore))
Closefile(fileout)
Endfunction
Function NewHighscoreFile()
Local fileout as Integer
fileout = OpenToWrite(HIGHSCORE_FILE$,0)
WriteLine(fileout, str(0))
Closefile(fileout)
EndFunction
I work on Linux.