sdfsf93924554234fjfjf
01-27-2008, 07:09 PM
hi,I'm working on an app at the moment that is bringing in database data. To use that data in MS I want to convert the raw table into a nested table. Ideally, this would be a 3 level deep nested table (array) with various types of info stored in it. Some info would just need the 1 or 2 levels, whilst others would need all 3. i.e.
order[1][1][1]
would store...
order.items.item1.item Name
or
order.items.item2.item2 quantity
or
order.InvoiceNumber
or
order.deliveryType
Problem is... I can't grasp from the docs how you exactly create a dynamic nested array of this kind. Is this even possible? In other scripting languages I would expect to define the original array (order[][][]), and then to be freely able to add values to it ad-hoc, and for the table to adjust as needed. But what I actually find is that assigning say...
order[1][1] = "funky";
works. Whilst..
order[13][1] = "bummer";
does not....
If nested tables in LUA are not dynamic, it looks like I'll just have to forget the whole nested system and go for a much flatter (and harder to code model).
And guidance appreciated here. Does anyone have any extensive examples of how to create and work with nested arrays? Can they be fully dynamic i.e. can I simply assign values to any level of the nest and LUA will create the tables as needed on the fly?
Cheers
Chris
order[1][1][1]
would store...
order.items.item1.item Name
or
order.items.item2.item2 quantity
or
order.InvoiceNumber
or
order.deliveryType
Problem is... I can't grasp from the docs how you exactly create a dynamic nested array of this kind. Is this even possible? In other scripting languages I would expect to define the original array (order[][][]), and then to be freely able to add values to it ad-hoc, and for the table to adjust as needed. But what I actually find is that assigning say...
order[1][1] = "funky";
works. Whilst..
order[13][1] = "bummer";
does not....
If nested tables in LUA are not dynamic, it looks like I'll just have to forget the whole nested system and go for a much flatter (and harder to code model).
And guidance appreciated here. Does anyone have any extensive examples of how to create and work with nested arrays? Can they be fully dynamic i.e. can I simply assign values to any level of the nest and LUA will create the tables as needed on the fly?
Cheers
Chris