From: "Andy Bushnell" <andy@carbongraphics.com>
Reply-To: Lua list <lua@bazar2.conectiva.com.br>
To: <lua@bazar2.conectiva.com.br>
Subject: C Function returning a table to LUA?
Date: Mon, 29 Sep 2003 01:18:13 -0600
Hi,
Please excuse my ignorance (i'm a Lua newbie).
I have a 'C' function (getFileListing) that has been registered with Lua.
It
compiles a list of files in the current working directory. Everything works
fine until I try *returning* this info to Lua. How can I do it?
My Lua script (right now) makes the call...
getFileListing()
Nothing happens but printf's in the getFileListing function show that its
being called & doing the right thing. So now I have an array of strings
(the
file names) in the 'C' side but I want to pass this info back to the
script.
I think I need to use a "Table" to pass this info to Lua, but tables are
new
to me and I cant see an example which does what I want (which, as a newbie,
im looking for!).
I'd like my script (I think) to look something like ...
t = getFileListing() -- where t is the returned table
-- check for table size
-- iterate through table getting the file listing names
(im not sure of the exact table iteration syntax - but I can work that out
later).
I hope this isnt too simple a question - but any help would greatly
appreciated.
Regards,
Andy