Creating a list from hard coded variables

Hi there,

The situation:

I am working on an app which has a list of items that can have their quantities adjusted. Now what I am trying to do is get those items, if their quantity is greater than 0, to appear on a list on another screen (kind of like a online shopping basket)

The problem:

I can not think of a logical way of coding the other screen to display these items, making the positions dependant on the quantity… (probably best to sort in order of item#)

So for example:

Item 1 qty = 1

Item 2 qty = 0

Item 3 qty = 4

Item 4 qty = 0

Item 5 qty = 0

Item 6 qty = 3

The list should show like this on the screen:

line1:      Item 1

line2:      Item 3

line3:      Item 6

I have been contemplating different methods of getting this done all day but always hit a very solid steel reinforced wall before my method sees light :frowning:

Any help would be greatly appreciated :smiley:

Cheers

Daine

It really depends on how the display objects are coded to appear, but seemingly you just need to be doing checks.

-- first, assume all of these items are in a table local items = {} items[1] = "Item 1" -- (or whatever you're calling it) items[2] = "Item 2" -- etc.... for i = 1, #items do if items[i].quantity \> 0 then -- show it... end

It really depends on how the display objects are coded to appear, but seemingly you just need to be doing checks.

-- first, assume all of these items are in a table local items = {} items[1] = "Item 1" -- (or whatever you're calling it) items[2] = "Item 2" -- etc.... for i = 1, #items do if items[i].quantity \> 0 then -- show it... end