lua-users home
lua-l archive

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


> I'd like to accumulate stdio to a buffer.

The easiest way is to redefined the functions that write to stdout.
For instance, like this (untested):

local buffer={}
local bufsiz=0

function print(...)
	local t=table.pack{...}
	for i=1,t.n do t[i]=tostring(t[i]) end
	bufsiz=bufsiz+1
	buffer[bufsiz]=table.concat(t,"\t",1,n)
end

At the end, send table.concat(buffer,"\n") back to the client.