[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: reading table values using debug.getlocal
- From: "Wojciech L. J\eadruch" <dendro8@...>
- Date: Fri, 06 Feb 2009 10:18:37 +0100
Solution was simplier, then i expected. Case is closed.
i just added code, in place when there's a table :
for i=1,10 do
k, v = debug.getlocal(1,i)
print( tostring(i) .. " " .. tostring(k) .. " = " .. tostring(v))
if i == 3 then
print (tostring(v) .. " " .. type(v))
for k1,v1 in pairs(v) do
print( tostring(k1) .. " = " .. tostring(v1))
end
end
Dnia 6 lutego 2009 9:57 Wojciech L. J\eadruch <dendro8@o2.pl> napisał(a):
> 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
>
> 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)
>
> and the output:
>
> 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
>