lua-users home
lua-l archive

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


Hi Noel,

Since you didn't mention what the solution was...

Noel Frankinet wrote:
so far so good
now I want to decode that table ({"one","two","three"})

and I use
  string & TableToXml(lua_State *L)
  {  static string ret;
     ret.clear();
     lua_pushnil(L);  /* first key */
     while (lua_next(L, -1) != 0)

Shouldn't that be lua_next(L, -2)? You pushed nil, so the table's no longer the TOS.

     {
       ret += "<ITEM>";
       ret +=  luaL_checkstring(L, -1);
       ret += "</ITEM>";
lua_pop(L, 1); /* removes `value'; keeps `key' for next iteration */

Keeping 'key' at the TOS implies that the table is still one below it. Hope that was it.

Jack