Hi there!
On Sun, Nov 1, 2009 at 12:39 PM, andris <and
...@seznam.cz> wrote:
>...
> How would I get all the output of the interpreter back to display to
> user?
There's no output from the interpreter itself. Not for Eval anyway.
If the code says "print 'Hello!'" it would simply go to stdout.
There's this helper class ConsoleCapture that can be used for
capturing stdout somewhat conveniently:
import Boo.Lang.Interpreter
interpreter = InteractiveInterpreter2()
using console = ConsoleCapture():
interpreter.Eval("print 'Hello!'")
assert 'Hello!' == console.ToString().Trim()
> Stdout can't probably be redirected, because that's used by the
> host application for logging already, that must not mix up.
So the above won't work for you I guess....
> I can
> explore CompilerContext.Warnings and CompilerContext.Errors in the
> result of Eval(), but don't see a way to display results of the
> evaluation.
You mean the value of the last evaluated expression? You can access
through the LastValue property but you must ask the interpreter to
remember it:
import Boo.Lang.Interpreter
interpreter = InteractiveInterpreter2(RememberLastValue: true)
interpreter.Eval("2 * 21")
assert 42 == interpreter.LastValue
Cheers,
Rodrigo