We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
In order to interact with a script, it is useful to be able to modify and retrieve the values of global variables.
For example, say we have the following javascript file (c:\test.js):
interop = interop + 5
The following c# code initializes, then outputs the value of the "interop" variable.
var engine = new Jurassic.ScriptEngine(); engine.SetGlobalValue("interop", 15); engine.ExecuteFile(@"c:\test.js"); Console.WriteLine(engine.GetGlobalValue<int>("interop"));
This code outputs "20" to the console.
Note that you can only set the value of a variable to a supported type.
Next tutorial: Creating objects and arrays