lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello again,

Thanks for the reply, unfortunately it's not the answer. The code works fine
in every other instance for parsing tables, the problem only occurs when
data is entered into the table without a key, and I'm assuming the default
keys 1,2,3,4... apply in this case.

So probably the error is within this change of keys. It sounds like a confused stack! I've searched these problems by myself :-)


They first default key, 1, is returned for line1, but on calling lua_next
for the next iteration, (key 1 being at the top level of the stack, and the
table being a level below, calling lua_next(l,-2) causes the application to
bomb out.

Did you verify that there actually is the key onto the stack in that case?

If I remember correctly the lua_next function works like that:

lua_pushnil(L); -- as the first key
while (lua_next(L, t) != 0) {
	-- the key is assumed on idx -2, the value on idx -1
	...

lua_pop (L, 1); -- pops one element on top of the stack (not the element -- on idx 1)
}

So maybe the "indirect" key is not pushed? Did you try to set the keys directly like that?

Dropdown1={xpos = 10, ypos=10, width=20, drop=100, 1 = “line1”, 2 = “line2”, 3 = “line3”}

The next thing to try would be to use only numerical keys.

What happens if you cut the table after line1, like that:
Dropdown1={xpos = 10, ypos=10, width=20, drop=100, 1 = “line1”}

If you do something with the stack afterwards, does Lua Crash also?

Regards,
Eva