lua-users home
lua-l archive

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


On Wed, Aug 11, 2004 at 03:34:45PM +0400, Dmitry Samersoff wrote:
> lua_tostring remove value from stack. Isn't it ?

No, it doesn't. There's your problem.

>  lua_pushstring(L, "RRN");
>  lua_pushstring(L, "abcd");
>  lua_settable(L,-3);

Because each iteration of the loop was adding an extra key-value pair
to the stach, the table is no longer at index -3, it's at index
-(num_keys*2+1).

Probably what you wanted was to do lua_pop(1) to remove the value
rather than re-pushing the key.

-- Jamie Webb