Yo!! I have fixed this apparently. I posted this message after three days of dilema and fixed it in the next 5 minutes :) After as bit of code here and there I seem to finally put all the pieces together and both out and err seems to be captured except for one thing that JythonEngine does not set the Message of the error in the Exception but displays the message in bsfexception.getTargetException().toString()!!! and Javascript/Beanshell puts the proper error message but I guess that all the Engines could be made standard with this respect.

On the other note the Plugin seems to have fixed/introduce two major enhancements and on my way to releasing a 0.2 release soon :)

Thanks for all your help,
Jiger




From: "Jiger Patel" <[EMAIL PROTECTED]>
Reply-To: "Bean Scripting Framework developers" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Capturing sysin and sysout
Date: Wed, 04 Jun 2003 11:46:09 +0530


Hi,
Is there someway to capture the sysout and sysin of any BSF Scripting engine. In my application I want to capture the output of a "print" or a "System.out.println" or any "console" out and show it on the GUI textarea. "Beanshell" and "javascript"(see note below) "seem" to be working but jython is playing some game. I tried redirecting System.out to a ByteArrayBuffer in the following way


ByteArrayOutputStream byOut = new ByteArrayOutputStream();
PrintStream  pOut = new PrintStream(byOut);
PrintStream oldStream = System.out;
System.setOut(pOut);
loadBSFManager(view);
bsfmanager.exec(bsfpanel.getCurrentLanguage(),filename,1,1,script);
pOut.flush();
printOutput(byOut.toString());
System.setOut(oldStream);
pOut.close();
pOut=null;
byOut = null;

But yet jython's "print" statement comes on the System.out logs but not in the byOut above. Other languages seem to work fine. Except Javascript which returns an org.mozilla.javascript.UndefinedFunction object in the eval but that is a for some other mail.

So can anyone suggest someway as to how to capture the sysouts and sysins in some language independent way or can BSF add Input and Output stream params to the exec/eval methods which the scripting engines can then enforce in the language dependent way. Or maybe some method like setIn and setOut in the BSFManager for the streams to be used by the scripting engines when they are initiailised.

Any ideas?

Thanking you,
Jiger.

_________________________________________________________________
Technical writer?. Earn more now! http://server1.msn.co.in/msnleads/tis/index.asp Find out how.



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________________
HCL Beanstalk PCs. You could win one. http://server1.msn.co.in/sp03/hclbeanstalktour/index.asp Interested?



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to