Hi,
I’m using these read / write functions to read / write a high score…
function writeToFile( data, filename, baseDirectory ) local baseDirectory = baseDirectory or system.DocumentsDirectory local path = system.pathForFile( filename, baseDirectory ) local file = io.open( path, "w" ) file:write( data ) io.close( file ) end function readFromFile( filename, baseDirectory ) local baseDirectory = baseDirectory or system.ResourceDirectory local path = system.pathForFile( filename, baseDirectory ) local file = io.open( path, "a+" ) local data = file:read( "\*n" ) io.close( file ) return data end
I call them like this…
function getHighScore() local score = tools.readFromFile("KeePeeUppy.txt", system.DocumentsDirectory) if (score == nil) then score = 0 end return score end function saveHighScore(score) tools.writeToFile( score, "KeePeeUppy.txt", system.DocumentsDirectory ) end
a print statement shows the score being written, but when I read back it’s always nil.
Any ideas?!?! TA 