lua-users home
lua-l archive

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


Hello Jeremy:

The problem is that in the second procedure, you create the table, retrieve its stack index, and then call lua_settable to make it a global variable. Calling lua_settable pops the newly created table from the stack, making your stored stack index invalid. Instead, that function should begin as follows:

 lua_newtable(L);
 tbl := lua_gettop(L);// get the table reference
 lua_pushstring(L, 'Params');
 lua_pushvalue(L, tbl); // push it again to make it a global
lua_settable(L, LUA_GLOBALSINDEX);//set the var name "Params" = table instance

To keep your pushes and pops balanced, the function should now have this at the end:

 lua_remove(L, tbl);

I hope this helps.

BTW, is this Delphi, or some other form of Pascal? I don't really know Pascal, but the relevant code was similar enough to C that I could follow it.

--
Matt Campbell
Lead Programmer
Serotek Corporation
www.freedombox.info
"The Accessibility Anywhere People"