Re: very simple doubt - declaring a method in the Interpreter
David <[email protected]> Wed, 20 Oct 2010 06:43:40 -0400
| Newsgroups | gmane.comp.java.beanshell.user |
|---|---|
| Message-ID | <[email protected]> |
i.eval("
int addTwoNumbers( int a, int b ) {
return a + b;
} " )
David A. Lee
[email protected]
http://www.xmlsh.org
On 10/19/2010 11:00 PM, Leonardo K. Shikida wrote:
> 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
> _______________________________________________
> Beanshell-users mailing list
> Beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
------------------------------------------------------------------------------
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