lua-users home
lua-l archive

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


Thanks. That is a good idea. Maybe that is what I will do. By the way, what
I am doing is making a Lua plugin for REALbasic such that you can call
scripts from within a REALbasic app. I whipped up a quick app that opens
scripts as text files and being able to execute them. I have a console
window that gets the output. I modified print() to capture that output but
write is a bit trickier. I think I have another solution that will also work
but I could easily implement your solution (I'll need to register some
function that will callback to REALbasic that I will call from write()).

> From: Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
> Reply-To: lua-l@tecgraf.puc-rio.br
> Date: Fri, 5 Jan 2001 08:55:48 -0200 (EDT)
> To: Multiple recipients of list <lua-l@tecgraf.puc-rio.br>
> Subject: Re: Trapping _OUTPUT
> 
>> Hi. I'm wondering what the best way to trap writes to _OUTPUT would be. I
>> don't want to just redirect output, I want to do something entirely
>> different. I could, I suppose, just modify io_write, but I really don't want
>> to do it that way.
> 
> How about redefining "write":
> 
> function write(...)
> if arg[1]==_OUTPUT or tag(arg[1])~=tag(_OUTPUT) then
> -- do something entirely different...
> else
> call(%write,arg)
> end
> end
> 
> --lhf
>