lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Yes that works for me also.  It also fits in better with my model.  So,
thanks again.  You're the best! :)

Chris Percival
Software Engineer
Interaxis Computing Ltd.
DDI:  +44 (0)1249 700072
http://www.interaxis.co.uk/

> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Luiz Henrique de
> Figueiredo
> Sent: 21 February 2002 15:16
> To: Multiple recipients of list
> Subject: RE: Registering a new function that wraps write(format())
>
>
> >Yes, but how would I do that from C?
>
> How about this (tested)?
>
> static int l_printf (lua_State *l) {
>  lua_getglobal(L,"format");
>  lua_insert(L,1);
>  lua_call(L,lua_gettop(L)-1,LUA_MULTRET);
>  lua_getglobal(L,"write");
>  lua_insert(L,1);
>  lua_call(L,lua_gettop(L)-1,LUA_MULTRET);
>  return lua_gettop(L);
> }
>
> lua_register(L,"printf",l_printf);
>
> --lhf