[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Stdout
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 29 Jan 2001 11:13:14 -0200 (EDT)
>Can I redirect output (ie. output from write()) into a memory buffer/Lua
>function without altering the Lua source?
Yes, by redefining write itself. Something like this:
_OUTBUF=""
function write(...)
if arg[1]==_OUTPUT or tag(arg[1])~=tag(_OUTPUT) then
local i0
if arg[1]==_OUTPUT then i0=2 else i0=1 end
for i=i0,arg.n do
_OUTBUF=_OUTBUF..arg[i]
end
else
call(%write,arg)
end
end
--lhf