very simple doubt - declaring a method in the Interpreter

"Leonardo K. Shikida" <[email protected]> Wed, 20 Oct 2010 01:00:24 -0200
Newsgroups gmane.comp.java.beanshell.user
Message-ID <[email protected]>
Hi

from the quickstart guide, I saw that I can declare methods just like this

>>
int addTwoNumbers( int a, int b ) {
    return a + b;
}

sum = addTwoNumbers( 5, 7 );  // 12
>>

and I saw I can declare variables and evaluate expressions using the
Interpreter just like this

>>
import bsh.Interpreter;

Interpreter i = new Interpreter();  // Construct an interpreter
i.set("foo", 5);                    // Set variables
i.set("date", new Date() );

Date date = (Date)i.get("date");    // retrieve a variable

// Eval a statement and get the result
i.eval("bar = foo*10");
System.out.println( i.get("bar") );
>>

now, my doubt is how can I declare a method using the Interpreter ?

TIA

[]

Leo K.

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev