contents   index   previous   next



SElib.compileScript(codeToCompile[, isFile])


codeToCompile - a string with ScriptEase statements or a filename of a script file.


isFile - a boolean telling whether or not codeToCompile is a filename or a string with statements. The default is false indicating that codeToCompile is a string consisting of ScriptEase statements.



buffer - the compiled code in a ScriptEase buffer. Normally, this buffer of compiled code is saved to a file.



Compiles a ScriptEase script into executable code which is normally written to a file with an extension of ".jsb" and referred to as a ScriptEase binary file. This compiled code is the same code that is created when the /bind option is used with the Pro version of ScriptEase Desktop and the code is bound in an executable ".exe" file.


Compiled code may be executed in two ways. First, the compiled code may be passed to the SElib.interpret() method as the Code parameter. The SElib.interpret() method executes compiled code in the same way that it does text script. Second, a ScriptEase binary file may be executed by a ScriptEase interpreter, such as sewin32.exe. This second way is the most common way to execute compiled code. There are three basic ways that a ScriptEase script file may be run:


A text script, as typed by a programmer, may be called using an interpreter program, such as sewin32.exe. The interpreter reads the text and performs all the statements in it. Running a script in this way results in the slowest overall execution speed since the interpreter must preprocess, tokenize, and run the file.

A text script may be compiled using the SElib.compileScript() method and written to a ScriptEase binary file. A ScriptEase binary file may also be called by an interpreter program, such as sewin32.exe. But overall execution time is faster since the first two steps, preprocessing and tokenizing, are already done by SElib.compileScript(). The compiled code of a script is the same as the compiled code of an executable file produced using the /bind option of the Pro version.

A text script can be compiled using the /bind option of the Pro version. The script is compiled, into the same form as when using SElib.compileScript() but is physically attached to the pertinent executable part of an interpreter, such as sewin32.exe. The compiled file is an executable file with an extension of ".exe" and can be run as a stand-alone program.



See the section on running a script in the manual or help file for more information on executing ScriptEase scripts.


ScriptEase binary files are called in the same way as text scripts, either ".jse" or ".jsh" files. Assume that a file named testobj.jse has been compiled with SElib.compileScript() to testobj.jsb. The invocations of either file by an interpreter do the same thing. For example, both lines below accomplish the same thing when run as a command line.


sewin32.exe testobj.jse sewin32.exe testobj.jsb


The second line using ".jsb" executes faster, in overall time, that is, it begins executing more quickly.


In a like manner, assume that a file named testinc.jsh has been compiled with SElib.compileScript() to testinc.jsb. Either file may be included in a script using the preprocessor directive #include. Both lines of script below accomplish the same thing.


#include "testinc.jsh" #include "testinc.jsb"


The second line executes faster since the code in that file is precompiled. This include example points to another difference between the /bind option and the SElib.compileScript() method. The /bind option results in a stand-alone executable file. The SElib.compileScript() method allows the flexibility of precompiling sections of code that may be used in other scripts or of having a complete precompiled program. Complete programs compiled by either method execute at the same speed, at actual run time.


A compiled ScriptEase binary file may also be run from a script by using the SElib.interpret() method, using the INTERP_COMPILED_SCRIPT flag.


A ScriptEase binary file has 4 bits that identify it as a compiled script and 16 bytes for a checksum to make sure that the file has not been altered. Compiled scripts are implemented at a very low level which allows ScriptEase binary files to be included in a script, as already described. But, there is another benefit. A programmer may use file extensions other than the default ".jsb".


ScriptEase comes with a script, compile.jse, which automates the process of compiling a text script to a ScriptEase binary file.



SElib.interpret(), SElib.interpretInNewThread(), SElib.bound(), sebind.jse, compile.jse



   // Compile the script file, myscript.jse,

   // to the ScriptEase

   // binary file, myscript.jsb.

function main(argc, argv)


      // Filename of the script to compile

   var infile  = "Myscript.jse";

      // Filename for the compiled code

   var outfile = "Myscript.jsb";


      // Compile the script file

      // into compiled code.

      // Argument true indicates that infile is a filename

   var compiledScript = SElib.compileScript(infile, true);


      // If the returned buffer has code in it,

      // save it to a file.

   if( compiledScript != null )


      var outfp = Clib.fopen(outfile, "w");

      if( outfp == null )



            "Could not open file \"%s\"\n",







            getArrayLength(compiledScript), outfp);