Grrr… I hate touch pads trying to navigate backwards when my swipe isn’t straight up and down…
Your data almost looks like JSON data. I think you just need square brackets [] around the outside. If your data is JSON formatted, then you can do something like this:
function loadTable(filename)
local path = system.pathForFile( filename, system.DocumentsDirectory)
local contents = ""
local myTable = {}
local file = io.open( path, "r" )
if file then
local contents = file:read( "\*a" )
myTable = json.decode(contents);
io.close( file )
print("Loaded file")
return myTable
end
print("file not found")
return nil
end
character\_array = loadTable("test.data")
Then you would end up with:
character_array[1].icon
character_array[1].caption
character_array[2].icon
character_array[2].caption
character_array[3].icon
character_array[3].caption
character_array[4].icon
character_array[4].caption
type data structure to use.
The data in JSON would look like this:
[{ "iconL": 17, "caption": "Item 2" },
{ "iconL": 17, "caption": "Item 3" },
{ "iconL": 17, "caption": "Item 4" },
{ "iconL": 18, "caption": "Item 5" },
{ "iconL": 18, "caption": "Item 6" }]
[import]uid: 19626 topic_id: 30814 reply_id: 123345[/import]