[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Listing/Enumerating global variables ?
- From: "Duncan Cross" <duncan.cross@...>
- Date: Sat, 22 Dec 2007 13:39:35 +0000
On Dec 22, 2007 1:32 PM, Lionel Fumery <lif-ml@mindtwist.com> wrote:
> Hello,
>
> I use the following code to create global variables :
> lua_pushnumber(m_LUA, Value);
> lua_setglobal(m_LUA, VarName);
>
> Is there a way to find / list / enumerate all those global variables,
> without knowing their name ?
>
> Thank you for your help,
>
> LiF.
>
>
Look into the lua_next API function, and use it with the
LUA_GLOBALSINDEX pseudo-index.
Alternatively if you want to get at them from inside a Lua script,
look into the pairs() function and the global variable _G, which is a
convenient reference to the globals table.