lua-users home
lua-l archive

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


Hi together,

i extract in a debug -view the content of local variables to show them in a editor.

how i become the content od a global variable from them name in a scriptline ?

for locals i extract the content in this example:

       CString varval,stackval,strtype;
       const char *p(0);

       for(int n(1); (p = lua_getlocal(lua, ar, n)) && (*p!='('); n++)
       {
           int type = lua_type(lua,n);

           switch(type)
           {
               case LUA_TNONE:
                    strtype  = "(illegal)";
                    stackval = strtype;
                    break;
               case LUA_TNIL:
                    strtype  = "(nil)";
                    stackval = strtype;
                    break;
               case LUA_TNUMBER:
                    strtype  = "(number)";
                    stackval.Format("%0.6f",lua_tonumber(lua,n));
                    break;
               case LUA_TBOOLEAN:
                    strtype  = "(bool)";
                    stackval.Format("%d",lua_tounsigned(lua,n));
                    break;
               case LUA_TSTRING:
                    strtype  = "(string)";
                    stackval = lua_tostring(lua,n);
                    break;
               case LUA_TTABLE:
                    strtype  = "(table)";
                    stackval = strtype;
                    break;
               case LUA_TFUNCTION:
                    strtype  = "(func)";
                    stackval = strtype;
                    break;
               case LUA_TUSERDATA:
                    strtype  = "(usrdat)";
                    stackval = strtype;
                    break;
               case LUA_TTHREAD:
                    strtype  = "(thread)";
                    stackval = strtype;
                    break;
               case LUA_TLIGHTUSERDATA:
                    strtype  = "(lightusr)";
                    stackval = strtype;
                    break;
               default:
                    break;
           }

           varval.Format("%s=%s %s",p,stackval,strtype);


Thanks for help.

Christmas greetings
Karsten

http://www.flexxvision.de/