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:
main(int argc,char **argv)
/* your application, including scripting. */
The other initialization task is to create an secontext. 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. You, as the API user, pass an secontext whenever you make a ScriptEase API call.
A single context may run more than one script one after the other but not simultaneously. 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 seCreateContext ScriptEase API call. The only required information for all versions is an seContextParams structure. You must fill one out and pass it as a parameter to seCreateContext. This structure is copied into the context on creation. 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, 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 seContextParams Structure