Scopes (PushScriptObject / BlockScope) -
07-15-2004
, 06:33 PM
Hi,
I'm trying to add different scopes to a VsaEngine and change variables
values in these scopes at will...
I'm currently doing:
eng.SetOption("fast", false);
ScriptObject so = new BlockScope(eng.ScriptObjectStackTop(),"scope1",1);
eng.PushScriptObject(so);
Eval.JScriptEvaluate("var v = 1;",eng);
ScriptObject so2 = new BlockScope(eng.ScriptObjectStackTop(),"scope2",2);
eng.PushScriptObject(so2);
Eval.JScriptEvaluate("var v = 2;",eng);
It's working fine since "v" exists twice once in "scope1" and once in
"scope2" with two differents values.
Now from here, here is what I would like to do:
Eval.JScriptEvaluate("scope1.v = 3;",eng);
Basically how can I reference directly the variable "v" in the "scope1" ?
I thought that BlockScopes names would be available as global properties but
they are not ...
Am I erronously using BlockScope or PushScriptObject ?
Is there any other/better way to create scopes ?
Thanks! |