Table questions

Just a few questions about tables.

  1. Is it possible to save tables to a text file, like a string? So that you could insert an item into a table, save it, and then load it next time to you play the app.

  2. Is it possible to insert one table into the other, so that if you have two tables with five values each, you could merge them to have one table with ten values? [import]uid: 116264 topic_id: 26031 reply_id: 326031[/import]

  1. Yes, you can either use ICE http://developer.anscamobile.com/code/ice or http://blog.anscamobile.com/2011/08/tutorial-exploring-json-usage-in-corona/

  2. Yes: For instance

  
local totalTable = {}  
  
local myTable1 = {  
 {val = 1},  
 {val = 1},  
 {val = 1},  
 {val = 1},  
 {val = 1},  
}  
  
local myTable2 = {  
 {val = 2},  
 {val = 2},  
 {val = 2},  
 {val = 2},  
 {val = 2},  
}  
  
for i = 1, #myTable1 do  
 totalTable[#totalTable + 1] = myTable1[i]  
end  
  
for i = 1, #myTable2 do  
 totalTable[#totalTable + 1] = myTable2[i]  
end  
  
print(#totalTable)  

[import]uid: 84637 topic_id: 26031 reply_id: 105898[/import]

thanks, very useful. [import]uid: 116264 topic_id: 26031 reply_id: 106343[/import]