So i have read lots of posts and also followed an example in the code exchange on how to save and read data to a text file. this is great. What i cannot figure out is how to then make use of the data. for example this is my working code:
local path = system.pathForFile( "times.txt", system.DocumentsDirectory )
local file = io.open( path, "r" )
local function resumeStart()
if file then
print("opening text file")
local contents = file:read( "\*a" )
-- separate the variables into a table using a helper function
local prevState = explode(", ", contents)
print(prevState)
end
end
function explode(div,str)
if (div=='') then return false end
local pos,arr = 0,{}
-- for each divider found
for st,sp in function() return string.find(str,div,pos,true) end do
table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
pos = sp + 1 -- Jump past current divider
end
table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider
return arr
end
--]]
local function init()
resumeStart()
end
init()
So my question is how do i use the value that it reads from the text document, i am trying to save a high score for example. when my code is run it displays “table: A304983” for example. so its grabbing the value but how do i now actually use it? hope that makes sense, thank you [import]uid: 19620 topic_id: 7963 reply_id: 307963[/import]