This is how its done:
local table = {table = {‘1’,‘2’,‘3’,‘4’,‘5’}}
When I try to use #table.table it returns 0. Any Ideas how it’s done?
Thanks in advance
This is how its done:
local table = {table = {‘1’,‘2’,‘3’,‘4’,‘5’}}
When I try to use #table.table it returns 0. Any Ideas how it’s done?
Thanks in advance
I’m not sure how you would do it in that situation but if you change the table to this it would work:
[lua]local table = {table = {“1”}, {“2”}, {“3”}, {“4”}, {“5”} }[/lua]
But thats probably not what you’re looking for. Here is a great page that explains tables and is really useful. You can just scroll down and look for an example that looks like what you are trying to do.
http://www.coronalabs.com/blog/2011/06/21/understanding-lua-tables-in-corona-sdk/
Hope it helps 
@lwq
Your example works for me, but read on FWIW, I’m lost as to why.
I believe you are declaring each table as a string instead of an indexed table, like table.table[1] for example.
I don’t believe lua will include tables declared as strings in the table length.
If you index each table like this, it works. From my limited experience, Ima newb btw, creating and iterating over tables that are indexed is the way to go imo.
[lua]
local table = {table = { 1, 2, 3, 4, 5 }}
print("#table.table == "… #table.table)
[/lua]
I’m sure someone else could explain better, but I think this is what’s going on…
EDIT:
Sorry, I didn’t think lua would include string named tables in the length, but I’m wrong here. Your example works form me, you may have a typo?
Try this…it prints the correct table length for each table. hmmm…I seldom name tables as “strings”, but I didn’t think it would work.
Here I thought I understood lua tables fairly well, has lua been modified or has this always worked? Rob or anyone?
[lua]
local table = {table = { 1, 2, 3, 4, 5 }}
print("#table.table == "… #table.table)
local table2 = {table = { ‘1’, ‘2’, ‘3’, ‘4’, ‘5’ }}
print("#table2.table == "… #table2.table)
print("table2.table[3] == "… table2.table[3])
local table3 = {table = { “Go”, “Stop”, “Red”, “Blue”, “Green” }}
print("#table3.table == "… #table3.table)
print("table3.table[3] == "… table3.table[3])
[/lua]
Nail
I’m not sure how you would do it in that situation but if you change the table to this it would work:
[lua]local table = {table = {“1”}, {“2”}, {“3”}, {“4”}, {“5”} }[/lua]
But thats probably not what you’re looking for. Here is a great page that explains tables and is really useful. You can just scroll down and look for an example that looks like what you are trying to do.
http://www.coronalabs.com/blog/2011/06/21/understanding-lua-tables-in-corona-sdk/
Hope it helps 
@lwq
Your example works for me, but read on FWIW, I’m lost as to why.
I believe you are declaring each table as a string instead of an indexed table, like table.table[1] for example.
I don’t believe lua will include tables declared as strings in the table length.
If you index each table like this, it works. From my limited experience, Ima newb btw, creating and iterating over tables that are indexed is the way to go imo.
[lua]
local table = {table = { 1, 2, 3, 4, 5 }}
print("#table.table == "… #table.table)
[/lua]
I’m sure someone else could explain better, but I think this is what’s going on…
EDIT:
Sorry, I didn’t think lua would include string named tables in the length, but I’m wrong here. Your example works form me, you may have a typo?
Try this…it prints the correct table length for each table. hmmm…I seldom name tables as “strings”, but I didn’t think it would work.
Here I thought I understood lua tables fairly well, has lua been modified or has this always worked? Rob or anyone?
[lua]
local table = {table = { 1, 2, 3, 4, 5 }}
print("#table.table == "… #table.table)
local table2 = {table = { ‘1’, ‘2’, ‘3’, ‘4’, ‘5’ }}
print("#table2.table == "… #table2.table)
print("table2.table[3] == "… table2.table[3])
local table3 = {table = { “Go”, “Stop”, “Red”, “Blue”, “Green” }}
print("#table3.table == "… #table3.table)
print("table3.table[3] == "… table3.table[3])
[/lua]
Nail