[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: finding length of a table
- From: "Vaughan McAlley" <ockegheim@...>
- Date: Mon, 4 Aug 2008 12:16:54 +1000
You nearly had it:
2008/8/4 Hans van der Meer <H.vanderMeer@uva.nl>
>
> >> if t then for k,v in pairs(t) do print(k,v) end end
>
function CallThisFromC(t)
local count = 0
if t then for k,v in pairs(t) do count = count + 1 end end
return count
end
For the complicated way, add a count to lua_next
http://www.lua.org/manual/5.1/manual.html#lua_next
Matthew Burke is correct, though now table.foreach is deprecated:
http://www.lua.org/manual/5.1/manual.html#7.2
Vaughan