lua-users home
lua-l archive

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

Jack Pham a écrit :
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;
     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.


Yes exactly,
Found by trial and error however ! (I still don't really understand the stack architecture, but its coming). I now want to enter table of tables of tables (for listview and treeview control) !
Thank you
Best wishes

Noël Frankinet
Gistek Software SA