Re: How to access objects from the script?

Brian Hawkins <brianhks-BYHubErIwDGZvNlLnfxc/[email protected]> Thu, 16 Mar 2006 10:17:12 -0700
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
This is how I've done it.

I call set on the interpreter class to set an object into the 
environment like so
m_interpreter.set("bshargs", args);

This sets args as the variable "bshargs" (this name can be anything);

Then I call

m_interpreter.eval("on_start(bshargs)");

This calls the "on_start" method and passes the bshargs variable that I 
set earlier.  The object passed in can be any real or script object.

Brian

Philip Cammin wrote:

> Hello!
>
> I would like to call different methods which are written in a 
> beanscript file at certain points in my application. For example i do 
> call the method "on_start()" in the "public static void main(String 
> args[])" method of my application. And i, ofcourse can give the method 
> strings and integers, but i did not find an example to give the 
> method, a reference to an object. Also i did not find out how to 
> modfiy objects or variable which are in the real java code from the 
> script, if i only had the reference to it.
>
> I just want to offer the oppertunity for the users to get or set data 
> in the program at different points, i do not want to to script the 
> whole classes.
>
> Thank you!
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting 
> language
> that extends applications into web and mobile media. Attend the live 
> webcast
> and join the prime developer group breaking into this new coding 
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Beanshell-developers mailing list
> Beanshell-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/beanshell-developers
>
brianhks.vcf (text/x-vcard, 206 B)
begin:vcard
fn:Brian Hawkins
n:Hawkins;Brian
email;internet:brianhks-BYHubErIwDGZvNlLnfxc/[email protected]
tel;home:801-754-1383
tel;cell:801-361-2845
x-mozilla-html:TRUE
version:2.1
end:vcard