Initialization and Contexts
Initialization is necessary before you can actually perform the tasks related to executing scripts. The first task is to initialize the engine itself. Your application only does this once when it starts and terminates the engine once when it exits. Even if you are running multiple threads in your application and running many different scripts, you only initialize the engine once. Here is a code snippet demonstrating initializing and terminating the engine:
static public final void main(String argv)
/* your application, including scripting. */
The two initialization methods (seInitialize() and seTerminate()) are static members of the SE object. The SE object contains all the API initialization methods along with all of the constants used by the API.
The other initialization task is to create an SEContext object. This is a handle that ties all of your scripting together. Each script you wish to run needs a context. It holds the variables, functions, preprocessor defines, and all the other information a script needs. All of the API calls are methods of the SEContext object.
A single context may run more than one script one after the other but not simultaneously. Therefore, if you want to run multiple scripts at once, such as in a multithreaded application, each thread will need its own context. You can create as many contexts as you like. Most applications will create a single context that is used for the life of the application then destroyed.
To create a context, you must use the SE.seCreateContext ScriptEase method. The only required information for all versions is a context parameters object. The context parameters object implements the SEContextParams interface and is passed as the first parameter to seCreateContext. The newly created context keeps a reference to the parameter object. The second parameter is a string. If you are using a trial version of the ScriptEase ISDK, you must give your userkey provided to you by Nombas. If you do not do so, the trial version will fail in its construction of a new context and return null. If you have a purchased version of ScriptEase, this second parameter is ignored.
The ScriptEase Context Parameter Interfaces