> I'm having trouble getting standard output from BeanShell. The Beanshell
> command print() is supposed to print it's argument, but when I enter
> print("Hello") into the BeanShell console, nothing happens. Some other
> BeanShell commands like pwd() also don't seem to put output anywhere.
>
> How do I direct BeanShell output somewhere specific, like to the Console
> plugin's buffer? Do I use bsh.interpreter.setConsole somehow?
>
> For that matter, if I evaluate System.out.println("Hello") in the
> BeanShell
> console, nothing happens either, but I imagine it's the same issue.
>
Try just entering "Hello". BeanShell will evaluate it and return the string
literal.
If you want a macro to print arbitrary text in the Console window, this will
illustrate what you should do:
// Write_to_Console.bsh
manager = view.getDockableWindowManager();
manager.addDockableWindow("console");
console = manager.getDockableWindow("console");
if(console == null)
Macros.error(view, "You must install the Console plugin to run this
macro.");
else
{
console.printPlain("This is plain text in black.");
console.printInfo("This is an attractive green.");
console.printWarning("This is hard-to-read orange text.");
console.printError("And this is bright red for those messages "
+ "that just won't wait.");
}
// end Write_to_Console.bsh
Here is an excerpt from a old thread which may be helpful.
John
<<<quote>>>
BeanShell does have built-in commands which are implemented in BeanShell
script.
You can find 'pwd', for example, in ./bsh/commands of your jEdit
installation. The problem is that jEdit does not grab the BeanShell
interpreter's output, only a script's return value. In BeanShell, 'pwd()'
calls BeanShell's built-in 'print()', which returns void. So when you call
'pwd()', BeanShell doesn't complain, but you don't see anything.
To get what you're looking for, you can adapt the contents of the built-in
scripts to return a String. For example, typing 'bsh.cwd' gets you the
output of BeanShell 'pwd()'.
John
-----Original Message-----
From: jedit-users-admin@...
[mailto:jedit-users-admin@... Behalf Of Dirk
Moebius
Sent: Monday, February 19, 2001 6:00 AM
To: jedit-users@...
Subject: Re: [ jEdit-users ] bean shell commands
> why can't I see any output from beanshell commands.
> If I type for example pwd(); nothing is displayed.
<<<endquote>>>
|