I Need my game write and read the “toprecord” on a file, so keep this info btween sesssios.
this is my code… How I make it works?
Thanks
function writefile()
local path = system.pathForFile( “cfl.txt”, system.DocumentsDirectory )
– Open the file handle
local file, errorString = io.open( path, “w” )
if not file then
– Error occurred; output the cause
print( "File error: " … errorString )
else
– Write data to file
file:write( toprecord )
– Close the file handle
io.close( file )
end
file = nil
end
function readfile()
local path = system.pathForFile( “cfl.txt”, system.DocumentsDirectory )
– Open the file handle
local file, errorString = io.open( path, “r” )
if not file then
– Error occurred; output the cause
print( "File error: " … errorString )
else
– Read data from file
local contents = file:read( “*a” )
contents = toprecord
toprecordtxt.text = toprecord
– Output the file contents
print( "Contents of " … path … “\n” … contents )
– Close the file handle
io.close( file )
end
file = nil
end
readfile()