lua-users home
lua-l archive

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


Hi all,

I have a problem when I want to access array as a table through C API.
Please consider this code:

in lua> enum = { 'one', 'two', 'three' };

in c >
lua_getglobal( L,"enum" );
lua_pushnil(L);
while( lua_next(L,1) ) {
    key = lua_tostring(L,-2);
    val = lua_tostring(L,-1);
    lua_pop(L,1);
}

First itertion gives me good results (ie. key/val = 1/one), but second
iteration is terminated in lua_next (application falls down).

If I try to access the fields via lua_rawgeti(L,1,i) it works fine.

Could you please give me a hand on this?

Thank you
Roman Vanicek

XTG Systems, s.r.o.
vanicek@xtg.cz