For my web browser example (http://www.esp8266.com/viewtopic.php?f=19&t=611&start=40) I need a way to execute a Lua statement thats in a string variable AND return the result in a string. Even better, some kind of multiline string as input, and a multistring as output.
I had a look at loadstring ( http://www.gammon.com.au/scripts/doc.php?lua=assert). That executes my string nicely.
> s=assert (loadstring ("print 'hello, world' print(tmr.now())")) ()
But….. the result is "just" printed, and not assigned to the variable s as I had hoped
I had a QUICK look to node.input, knowing that it would not return a result on the command line, I naively did anyway. Yep, no dice:
Just to be clear : if the Lua statement is executed OK, I want the result of the code returned into a variable. If the Lua statement contains an error I would like the error-line returned into a string variable (ref. the error line in the code below):
> s=assert (loadstring ("rint 'hello, world' print(tmr.now())")) ()
lua: [string "rint 'hello, world' print(tmr.now())"]:1: attempt to call global 'rint' (a nil value)
Put my nose in the right direction, please?