contents   index   previous   next



SElib.interpret()

syntax:

SElib.interpret(codeToInterpret[,

                howToInterpret[, security]])

where:

codeToInterpret - a string with ScriptEase code statements to be interpreted as script statements or the file specification, path and file name, of a script file. If the interpreted code receives arguments, they are put at the end of the codeToInterpret string--somewhat like a command line string.

 

howToInterpret - tells how to handle the interpreted code. The following flag values may be combined using the bitwise or operator, "|". The value must be 0 or one of the following choices:

 

INTERP_FILE
CodeToInterpret is the file name of a script, followed by any arguments.

INTERP_TEXT
CodeToInterpret is a string of source code with no arguments attached.

INTERP_LOAD
Load code into same function and variable space as the script that is calling SElib.interpret(). All functions, and variables are supplied to the code being called, which can modify and use them. If the code being called has similarly named functions or variables as the calling code, functions in the called code replace those in the calling code.

INTERP_NOINHERIT_LOCAL
Local variables are not inherited by the interpreted code.

INTERP_NOINHERIT_GLOBAL
Global variables are not inherited by the interpreted code as globals.

INTERP_COMPILED_SCRIPT
Run a script compiled with SElib.compileScript(). This flag only works with the INTERP_TEXT flag.

INTERP_FILE and INTERP_TEXT are mutually exclusive. If neither is supplied the interpreter decides whether codeToInterpret is a file or string of code.

 

These flags tell the computer how to interpret the parameter codeToInterpret. If one is not supplied, the computer parses the string and determines the most appropriate way to interpret it.

 

security – the filename of the security script to run this interpreted script using. This is exactly like the security script passed to SEdesk using the "/secure="option, except it applies only to the script you are about to interpret. Remember that security is additive; any existing security is still in effect for the interpreted script as well.

 

return:

value - the return of the interpreted code.

 

description:

Interprets a string as if it were script. More flexible than the JavaScript global.eval() function since it interprets a file as well as a string and allows more control over how interpreted code inherits variables from the script that calls SElib.interpret(). By default, all variables in a script are inherited as global variables.

 

There is no specific return for an error. To trap an error use the try/catch error trapping statements.

 

The SElib.interpret() method may not be used with scripts that have been compiled into executable files using the /bind option of the Pro version of ScriptEase Desktop.

 

see:

SElib.interpretInNewThread(), SElib.spawn()

 

example:

   // The following interpreted code displays "Hello world"

SElib.interpret('Screen.writeln("Hello world")', INTERP_TEXT);

   // The following interprets

   // the file jseedit.jse with

   // autoexec.bat as an argument to the script

SElib.interpret("jseedit.jse c:\\autoexec.bat",

                INTERP_FILE);

 


SElib.interpretInNewThread()