|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Embedding the interactive interpreterHi, I'm embedding the interpreter into a C# app using the Boo.Lang.Interpreter.InteractiveInterpreter2 class. User input comes from a winform Control (RichTextBox) and I call the InteractiveInterpreter2.Eval(string code) method for any entered lines. How would I get all the output of the interpreter back to display to user? Stdout can't probably be redirected, because that's used by the host application for logging already, that must not mix up. 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. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Boo Programming Language" group. To post to this group, send email to boolang@... To unsubscribe from this group, send email to boolang+unsubscribe@... For more options, visit this group at http://groups.google.com/group/boolang?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Embedding the interactive interpreterI forgot the Boo version: 0.9.2.3383 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Boo Programming Language" group. To post to this group, send email to boolang@... To unsubscribe from this group, send email to boolang+unsubscribe@... For more options, visit this group at http://groups.google.com/group/boolang?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Embedding the interactive interpreterHi there! On Sun, Nov 1, 2009 at 12:39 PM, andris <andris@...> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Boo Programming Language" group. To post to this group, send email to boolang@... To unsubscribe from this group, send email to boolang+unsubscribe@... For more options, visit this group at http://groups.google.com/group/boolang?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Embedding the interactive interpreterHi, thanks for the tips, > 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: ConsoleCapture will help me, for application logging I have yet a LogFileListener that can be used, receives log messages and saves to file instead passing them to stdout, so stdout can be reserved for Boo atm. > You can access > through the LastValue property but you must ask the interpreter to > remember it: I see, the LastValue might be useful. But it turns out that I need the full console output more so that stuff like "for o in objects : print o" can be used. Best, Andris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Boo Programming Language" group. To post to this group, send email to boolang@... To unsubscribe from this group, send email to boolang+unsubscribe@... For more options, visit this group at http://groups.google.com/group/boolang?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |