Hello xtracer!
If you have script code in a string, you can use the
The script code in this case defines a function called TestMethod. To execute that function, you can use additional scripts:
Or, you can use the
Please let us know if you have additional questions.
Good luck!
If you have script code in a string, you can use the
Evaluate()
method to run it:string code = @" function TestMethod(testObj) { //some action return testObj; } "; engine.Evaluate(code);
engine.Evaluate("TestMethod(123)"); engine.Evaluate("TestMethod({foo: 123, bar: 'abc'})");
Script
property to execute the function directly, without parsing or compiling additional scripts:engine.Script.TestMethod(123);
Good luck!