contents   index   previous   next

Using seEval


Having created an SEContext, you use this context to invoke scripts via the ScriptEase API. The ScriptEase ISDK function to execute script code is seEval. This function has a large number of parameters to control its behavior and the behavior of executed code. This chapter is devoted to explaining seEval. Let's start with a simple example that uses default values for most of the parameters:


se.seEval("var a = 10;",SE.TEXT,



All of the null values indicate a parameter that we are not interested in providing, using the default value instead. This call as it is written will evaluate the simple script var a = 10;. The full prototype of seEval is as follows:



seEval(Object to_interpret,int interp_type,

       String text_args,SEObject stack_args,

       int flags,

       SEEvalParams params);


The function returns a boolean indicating whether or not the evaluation succeeded. It would not if the script to evaluate contains an error. In addition to indicating success or failure, the script returns a value using the return statement. This value returned from the script or function is stored in the SE.RETURN object. This means that if you invoke seEval in a wrapper function then immediately return from the wrapper function, the result of the evaluation is passed along as the result of your wrapper function. This is a useful technique which is used, for instance, to implement the ECMAScript eval function.


An important concept of an evaluation is that of the global object. All global variables in the script, as well as functions, are put into the global object. When the script completes, all variables and functions are still part of the global object. This means that additional calls to seEval will find the variables and functions from past calls. You can specify a particular global object in the params parameter to put these variables and functions in that object as is described below.


As was mentioned when describing error returns, once a context has an error as its return, any attempts to change the return value are ignored. Likewise, any calls to seEval are ignored for the same reason. It is the most reasonable course of action when some previous API call generated an error. You must first erase the error as was described if you want to use seEval.


Let's look at the parameters and explain their use.