On Fri, Sep 18, 2015 at 2:16 PM, Soni L. <fakedme+lj@xxxxxxxxx> wrote:
Exactly what I was looking for...thank you!
On 18/09/15 04:32 PM, Lance Thornblad wrote:
I've seen questions like this posted a lot, but haven't yet found thelocal temp = {}
solution I'm looking for...
I am looking to send the output of print to my own built-in console.
It's easy to simply replace the global function with my own C function.
However, I want it to work EXACTLY like the existing function.
When I do something like this with the built-in print...
local tc = ffi.typeof( "foo" )
print( tc )
The output is...
ctype<struct foo>
So my question is, how do I either...
1. Capture the print output as a string?
or
2. Get the name of a ctype?
Note that I don't know if option 2 will cover all cases, since print may
produce output from other types I haven't come across, yet. Still seems
useful to know. :)
print = function(...)
local l = select('#', ...)
for i=1, l do
temp[i] = tostring(select(i, ...))
end
io.write(table.concat(temp, "\t", 1, l), '\n') -- This is your output.
Notice the '\n'!
end
(No idea if table.concat is JITted but meh w/e)