lua-users home
lua-l archive

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


jdarling@eonclash.com wrote:

Here we go, hopefully I don't fat finger anything in here :)

procedure LoadToArray(L : PLua_State; TableName : String; var LoadInto :
array of RecType);
var
 idxTable, idxTemp,
 idxSubTable : Integer;
 Key, SubKey : String;
 SubVal      : Double;
begin
 SetLength(LoadInto, 0);
 lua_pushstring(L, PChar(TableName));
 lua_gettable(L, LUA_GLOBALSINDEX);
 if lua_type(L, -1) <> LUA_TTABLE then
   raise exception.Create('Table expected for identifier
"'+TableName+'"');
 idxTable := lua_gettop(L);
 lua_pushnil(L);
 while (lua_next(L, idxTable)<>0) do
   begin
     SetLength(LoadInto, Length(LoadInto)+1);
I changed this line:

     Key := lua_tostring(L, -2);
in :

Key := lua_tostring(L, -2);
and it works now. Is it correct now?
Thanks!

jk