[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Redirecting output to non-files?
- From: Jens Alfke <jens@...>
- Date: Thu, 1 Dec 2005 15:03:17 -0800
It looks as though Lua's io package is hardwired to use the ANSI  
stdio library. The reference manual  says "a file handle is a  
userdata containing the file stream (FILE*)..." [5.6] There doesn't  
seem to be a way to 'subclass' file handles the way I could e.g.  
subclass java.io.OutputStream.
What I want to do is redirect Lua output to my own function, so that  
calls to print(), io.write(), io.output():write(), etc. all call my  
function so it can collect the output and do something with it.
(Apologies if I'm missing something obvious; I've used a lot of  
languages but I'm a newbie at Lua.)
--Jens