zeroday wrote:well I have been follow you posts everyday.
but I have no solutions in lua way, me a lua newbie too.
the first thing came into my head, is to make a api in C to do this,
take a lua statement, run it, and return a string result... but this is ugly...
Nice that you follow my struggle, thanks for your help.
Yep, an API in C, that's ugly , and too complicated for me!
I'm glad that I'm not missing anything obvious here.
But wait……
I think I have found A solution in the elua -httpd webserver http://wiki.eluaproject.net/lhttpd)
There's a docode function in it, that works in nodeMco too. I takes a Lua statement as input in a string, executes the loadstring of the string, and returns the result in a string. It works by a temporary replacement of the print function by a function that prints to string. Neat huh!
I did a quick test:
> s=[[print(node.heap())]]
> a=docode(s)
> =a
16384
> s='for i=1,3 do print(i) end'
> out=docode(s)
> =out
1
2
3
> s='now introduce a lua error for i=1,3 do print(i) end'
> out=docode(s)
> =out
>>> Invalid Lua code <<<
>
My problem can be solved in this way, I guess.