[Resolved] Saving and retrieving table data

So a while back, some great people helped me setting up using random numbers to pull information from an XML file. I decided to expand that, but am at a loss.

So what I am doing is loading an XML file:
[lua]local gameQuestions = xml:loadFile( xmlFilename, system.ResourceDirectory )[/lua]

I then parse that XML file and put the data in a table:
[lua]local standardQuestions = {}
local standardQuestions = gameQuestions.child[1][/lua]

I then figure out what the last question in the file is, so I know what to randomize to:
[lua]lastStandardQuestion = gameQuestions.properties[“finalQuestion”]
lastStandardQuestion = tonumber(lastStandardQuestion)[/lua]

I then set up a table of numbers of the questions to pick from:
[lua]local numbersStandardQuestions = {}
for i = 1,lastStandardQuestion do
numbersStandardQuestions[#numbersStandardQuestions+1] = i
end[/lua]

And then I go and set up the 9 questions:
[lua]for i = 1,9 do
math.randomseed( os.time() )
math.random()

local pos = math.random(1,#numbersStandardQuestions)
local num = numbersStandardQuestions[pos]
ques[i] = {
//Setting up XML strings here
}
table.remove (numbersStandardQuestions,table.indexOf(numbersStandardQuestions, num))
end[/lua]

At this point, I do nothing else with the standardQuestions and numbersStandardQuestions table data. Everything I need is in the ques table.

What I would like to do now is to save the table of data which has the unchosen questions to a file that I can load on the next play of the game, and choose from the unchosen values so that the user gets to play all the questions before getting repeats.

So the detection would be if this save file exists, load and use that instead of choosing from all the questions. If there are less than 9 questions available, then just use the complete selection of questions and not just the unchosen values.

I’ve used ICE before on saving information, but this seems like something different. So a little confused as to what would be the best way to go about this.

Would definitely appreciate if someone has some time to explain it to me. [import]uid: 17827 topic_id: 23955 reply_id: 323955[/import]

It helps if you look at the sample code:
http://developer.anscamobile.com/content/save-table

:slight_smile:

That code is causing a problem, but I will start a different thread about that. [import]uid: 17827 topic_id: 23955 reply_id: 97614[/import]