Hi Sergio,
I think you end up with val being the value of foo, rather than the
reference to foo. So what ends up happening is something like "5 =
101;". Try this instead:
a.lookupInScope("foo").opAssign(...)
What you are trying used to work long ago, but then I realized that
it had the result that someone could do something like "someFxn() =
3;", which could let the caller modify private members of an object
accessed thru an accessor function, which isn't good. I need to
update the embedder's guide... it is a bit out of date in this respect.
-- Rob
On Sep 7, 2005, at 4:53 AM, Sergio Szychowski wrote:
>
> Hi,
> when you want to assign a new value to a Value object, un exception is
> thrown.
>
>
> Scope b = new BasicScope( OscriptInterpreter.getGlobalScope() );
>
> try {
> Value val = OscriptInterpreter.eval("var foo = 1;", a);
> System.out.println("val= " + val ); // prints (null)
> val = OscriptInterpreter.eval("foo = 1 + 4;", a);
> System.out.println("val= " + val ); // prints 5
>
> val.opAssign(JavaBridge.convertToScriptObject(101));
> //throws exception
> //oscript.exceptions.PackagedScriptObjectException:
> NoSuchMemberException: no such member: ExactNumber: =
>
> ....
> }
> ....
>
> Greetings.
>
>
|