DASpiderMonkey Changing Values of Simple Types

I am having an issue with changing the value of a simple type in my script. I want to pass a string or integer into the engine and change the value in my script and then return the new value out of the scripting engine.

So far…

Set variable

var
  v: variant;
begin
 with fEngine.Engine.Variables do begin
   v := 'this is a test';
   SetVariable('person',v);
 end;
end;

Script

function main_10047_10034(){
    person = "John Doe";
}

Get variable

var
  v: variant;
begin
 with fEngine.Engine.Variables do begin
   v := GetVarVariable('person');
   raise exception.create(vartostr(v));
 end;
end;

This should return John Doe as the exception message. What am I doing wrong?

Thanks

Hi,

you can’t change global variables via script.

I can suggest to use session variables or create custom method that changes global variable, like

function TBaseEcmaTest.SetPerson(args: array of variant): variant;
begin
  fEngine.Engine.Variables.ReplaceVarVariableValue('person',args[0]);
end;
..
//  d: TDAEcmaFunction;
    d := SetPerson;
    fEngine.Engine.Variables.SetVariable('SetPerson',d);

usage in script:

          SetPerson("John Doe");

Ok thank you very much that worked.