> I'd like to be able to pass a variable into a BSF script, allow the
> script to change the value of the variable, and retrieve the changed
> value when the script has finished.
> I've tried:
> mgr.declareBean("Message", "OK", String.class);
> BSFEngine bsfEngine = mgr.loadScriptingEngine("groovy");
> bsfOut=bsfEngine.eval("script", 0, 0, "Message=\"123\"");
> returns the original value of the string, i.e. "OK"
> The script can set the value using
> but this is rather messy compared with being able to do:
> It would be nice if there was a way to access the variables themselves.
> Is this possible in BSF?
Well, this would be a feature of the BSF engine for your language
(accessing, changing, storing Java objects in the BSF registry).
Depending on the scripting language at hand making BSF registry entries
available transparently to your programming language as if they were
variables defined in the context of your script code could be
easy/simple (e.g. because it already supports Java bindings one way or
the other) or complicated (has no clues of Java at all, hence the
bridging/interfacing support needs to be created).