Setting and Reading variables after Execution

May 10, 2010 at 7:42 AM

Is there a way in the ScriptScope object where by i can set the variable to x to some dummy value then in my script that variable's value gets updated and then after the execution of the script I can read the updated value of the variable x. The code snippet would be as follows:

 

string script = "someVariable = \"Text123\"" ;

ScriptScope scope = ScriptHost.CreateHost();

scope.SetVariable("someVariable", "dummy");

CompiledCode code = ScriptHost.Compile(script);

code.Execute(scope);

object updatedValue = scope.GetVariable("someVariable");

at this point the value of updatedValue object would be Text123.  

If there a way to accomplish this would appreciate if you can provide me some pointers in the right direction.