This project has moved and is read-only. For the latest updates, please go here.

Accessing and modifying global variables

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);
This code outputs "20" to the console.

Note that you can only set the value of a variable to a supported type.

Next tutorial: Using the console API

Last edited Aug 25, 2010 at 2:50 PM by paulbartrum, version 6


No comments yet.