lua-users home
lua-l archive

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


Hi

Im trying to look at my table values, using debug.getlocal, but i dont have any clue how to do it. With debug.getlocal i have only obtained an adress of the table e.g. : tabl=table: 0x8d8fff0.
Here is a code which i have made 
<code>
function C(a,b)
  
  local t ={}
  t["idx_1"] = "val_1"
  t["idx_2"] = "val_2"
  --print(debug.traceback("----C----"))
  for K, V in pairs(debug.getinfo(1)) do 
    print(K, V) 
  end 
  
  print("stack frame 1")
  for i=1,10 do
    k, v = debug.getlocal(1,i)
    print( tostring(i) .. " " .. tostring(k) .. "=" .. tostring(v))
   end
  return c
end
C(1,2)
</code>
and the output:
<code>
source example1.lua                                                                                                           
what  Lua                                                                                                                     
func function: 0x8d90c20                                                                                                     
nups  0                                                                                                                       
short_src    example1.lua                                                                                                    
name  C                                                                                                                       
currentline  8                                                                                                               
namewhat  global                                                                                                          
linedefined   2                                                                                                               
lastlinedefined18                                                                                                                  
stack frame 1                                                                                                                   
1 a=1                                                                                                                           
2 b=2                                                                                                                           
3 t=table: 0x8d8fff0                                                                                                            
4 (for index)=4                                                                                                                 
5 (for limit)=10                                                                                                                
6 (for step)=1                                                                                                                  
7 i=7                                                                                                                           
8 nil=nil                                                                                                                       
9 nil=nil                                                                                                                       
10 nil=nil  

Thank You in advance for any help