problem with table ( please help me )

Oh, and you can’t iterate over a sparse table.

i.e. This won’t work as you might think:

btnstable[1] = " " btnstable[2] = " " btnstable[4] = " " for i = 1, #btnstable do print( btnstable[i] ) end

Do this instead:

for i = 1, 4 do print( btnstable[i] ) end

if you REALLY want a sparse table, then instead of insert(), do this:

t[3] = “whatever”

t[23] = “whatever”

t[93] = “whatever”

for k,v in pairs(t) do print(k,v) end

conversely, if you DON’T want a sparse table, then index it sequentially and iterate with for i=1,#t or ipairs()

right now you have half of one and half of the other, and that won’t work the way you seem to expect.  it’s not a bug in tables, it’s documented behavior - you just need to figure out if you want to treat your table as an “array” (with sequential numeric keys) or as a “hash” (with arbitrary keys), then populate and iterate appropriately.  if you mix the two, then the #count of the table becomes nonsense, so things like insert() won’t behave as you seem to expect.

ok thats work good.

many thanks :slight_smile: :slight_smile: :slight_smile:

best regards.