[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: newbie: parameterised scripts?
- From: Tony Wetmore <wetmore@...>
- Date: Mon, 6 Apr 1998 13:06:25 -0400
Paul Dixon [SMTP:email@example.com] wrote:
> After a call to lua_dofile on a script with no body, can I use
lua_callfunction to select the desired function?
When I was experimenting with Lua, this is exactly what I did. Any code
outside of the functions was executed during the lua_dofile(), while the
functions were simply defined for later reference via lua_callfunction().
Here is the main() driver source from my initial prototype -- the output
that is generated demonstrates how Lua's global (outside function)
statements are executed during the lua_dofile() call, but the code inside
function definitions is not:
int main(int argc, char* argv)
ret = lua_dofile("test.lua");
printf("Back from lua_dofile(), ret = %d\n", ret );
testFunction = lua_getglobal("TestFunction");
printf("Going to lua_callfunction(TestFunction)\n");
ret = lua_callfunction(testFunction);
printf("Back from lua_callfunction(TestFunction), ret = %d\n", ret);
Here is my test Lua script:
-- A program written to test Lua and figure out it works.
print('Starting global execution space.');
print('Back to global execution space.');