As noted in the section called “How jEdit Organizes Macros”, you can save a
BeanShell script of any length as a text file with the
.bsh
extension and run it from the
menu. There are three other ways jEdit lets
you use BeanShell quickly, without saving a script to storage, on a
“one time only” basis. You will find them in the
menu.
> > displays a text input dialog that asks you to type a single line of BeanShell commands. You can type more than one BeanShell statement so long as each of them ends with a semicolon. If BeanShell successfully interprets your input, a message box will appear with the return value of the last statement.
the section called “Predefined Variables in BeanShell”, this command defines the following:
> > displays a text input dialog that asks you to type a single line of BeanShell commands. The commands are evaluated for each line of the selection. In addition to the standard set of variables described inline
- the line number, from the start
of the buffer. The first line is numbered 0.
index
- the line number, from the start
of the selection. The first line is numbered 0.
text
- the text of the line.
Try typing an expression like (line + 1) + ": " +
text
in the dialog box. This will add a line number to each
selected line beginning with the number
1
.
The BeanShell expression you enter will be evaluated and
substituted in place of the entire text of a selected line. If you want
to leave the line's current text as an element of the modified line, you
must include the defined variable text
as part of
the BeanShell expression that you enter.
> > evaluates the selected text as a BeanShell script and replaces it with the return value of the statement.
Using
is an easy way to do arithmetic calculations inline while editing. BeanShell uses numbers and arithmetic operations in an ordinary, intuitive way.Try typing an expression like
(3745*856)+74
in the buffer, select it, and
choose
> > . The selected text will be replaced by the
answer, 3205794
.