lua-users home
lua-l archive

getting table indexes & values

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


What's wrong with the code above:
 VarName := lua_nextvar(pchar(#0));
 while VarName <> pchar(#0)
 do begin
 if lua_istable(lua_getglobal(VarName)) = 1
 then begin
 lua_pushobject(lua_getglobal(VarName));
 lua_pushnil;
 lua_callfunction(lua_getglobal('next'));
 Varindex:=lua_getstring(lua_lua2C(1));
 VarValue:=lua_getstring(lua_lua2C(2));
 ... //Do something with VarIndex & VarValue
	 while (Varindex <> (#0)) //loops forever!!!
 do begin
 lua_pushobject(lua_getglobal(VarName));
 lua_pushstring(Varindex); 
 lua_callfunction(lua_getglobal('next'));
 Varindex:=lua_getstring(lua_lua2C(1));
 VarValue:=lua_getstring(lua_lua2C(2));
 ... //Do something with VarIndex & VarValue
 end;
 end;
 VarName := lua_nextvar(VarName);
 end;
You can see I'm using Lua.dll...
It looks like the clone function, but doesn't work. My Experiences prove it
can't get the next table's index. Why? What's the best way to do this?
 (o,o) Pablo Saldo - ec4pas@super.furg.br
 {`"'} FUNDACAO UNIVERSIDADE FEDERAL DO RIO GRANDE
 -"-"- ENGENHARIA DE COMPUTACAO

AltStyle によって変換されたページ (->オリジナル) /