Hi,
Ok, I'm going to post the parsing code, so you can pick it to bits :)
void PrintTable(lua_State *L)
{
CString op;
int bah;
lua_pushnil(L);
while(lua_next(L, -2) != 0)
{
if(lua_isstring(L, -1))
{
if(lua_isstring(L, -2))
{
op.Format(_T("%s = %s\n"), lua_tostring(L,
-2), lua_tostring(L, -1));
}
else
{
op.Format(_T("%d = %d\n"), lua_tonumber(L,
-2), lua_tostring(L, -1));
}
}
else if(lua_isnumber(L, -1))
{
if(lua_isstring(L, -2))
op.Format(_T("%s = %d\n"), lua_tostring(L,
-2), lua_tonumber(L, -1));
else
op.Format(_T("%d = %d\n"), lua_tonumber(L,
-2), lua_tonumber(L, -1));
}
else if(lua_istable(L, -1))
PrintTable(L);
lua_pop(L, 1);
}
}
Cheers
Glen.
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Luiz Henrique de
Figueiredo
Sent: 25 September 2007 15:24
To: Lua list
Subject: Re: Lua_next probles
I'm using the standard c table parsing code that is described in the lua
manual. The issue appear to be when lua_next comes to parse the "line2"
data, "line1" is parsed correctly, with the key set to 1 as is expected,
but
the next iteration causes lua to bomb out. Tracing into lua reveal an
invalid key error.
You're probably not popping the value in the loop or using lua_tostring
on numerical keys. See http://www.lua.org/manual/5.1/manual.html#lua_next