Ok, I'm trying to match the output (nested table)of a command in the luaSQL extension. This returns a number of lines from a query, and each line has a number of records. So for instance a query returns a table with 10 lines. line 1 can have CUSTOMERNAME, ADDRESS, AGE, DOGCOLOUR etc
So I need to create a numerical table, with nested associative arrays in it. To be honest the AMS docs fall far far short in this area explaining anything this complex. The code below works....
recy ={};
recy[1] = {john="1",jack="2",dave="3"};
Debug.Print(recy[1]["dave"]);
Prints
>> 3
So.. with that working as planned, I tried to build the required associative array using a for loop and assignments based on the loop variables....
for index,item in records do
myTable[1] = {item=index};
end
Debug.Print(myTable[1]["item"]);
And this create an array in myTable[1], with one element called "item", and its value is "index". What I expected was a table with as many elements as were in the table "records", and each elements key to be the value stored in "record" for that iteration, and for the value stored to be the current for/loops "index" value.
So, how can I build an associative table within a for loop?
Cheers
Chris Thomas


