[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Problem with 'write(format()) ' wrapper
- From: "Chris Percival" <cpercival@...>
- Date: Wed, 20 Mar 2002 15:38:06 -0000
I have added a function Printf to my script using the following code:
int PrintfCmd(lua_State *L)
{
lua_getglobal(L,"format");
lua_insert(L,1);
lua_call(L,lua_gettop(L)-1,LUA_MULTRET);
lua_getglobal(L,"_PRINT");
lua_insert(L,1);
lua_call(L,lua_gettop(L)-1,LUA_MULTRET);
return lua_gettop(L);
}
_PRINT is my own function that displays text. If I call the Printf function
in the script with something like Printf(undeclared), then my _PRINTF
function gets NULL as a string. However if I call format(undeclared), then
I get the following error:
bad argument #1 to `format' (string expected, got nil)
I can't explain why this happens, is it anything to do with the above code,
or is there somthing else wrong? How could I fix it?
Thanks.
Chris Percival
Software Engineer
DDI: +44 (0)1249 700072
www.interaxis.co.uk