!EnBank supports JavaScript scripts V1.1 through V1.5 and adheres to ECMA-262 revision 3. It does this by means of JSLib32 which was ported from Mozilla's JavaScript engine and is available under Netscape's public Licence V1.1. You may obtain a copy of the License from www.mozilla.org and download the Source Code from their FTP site.
JavaScript itself is beyond the scope of this document, what follows is an overview of !EnBank's implementation of the JavaScript engine. If you want more information about the JavaScript language then the the Mozilla JavaScript pages might be a good place to start.
JavaScript is available from a number of places within !EnBank. Each of these scripting environments uses a separate run-time in order to better manage memory usage and 'garbage collection'. A run-time environment is the space in which the variables, objects, and contexts used by scripts are maintained.
Run-time environments:
Within a run-time, each script is maintained within its own context. A context is the script execution state for a thread used by the JavaScript engine. Each context has a name derived from the filename of the script. The exception to this is the Options run-time which uses a single Global context.
In addition to the standard JavaScript objects and functions !EnBank provides a number of additions. See the js directory supplied in the installation archive for details. Please note that not all provided objects are available for all scripting environments. For example, the Column object is only available from within the Import run-time environment.
Script errors fall into two categories:
Load-time errors, such as invalid syntax, are detected and reported when a script is enabled. It is not possible to enable a script that contains load-time errors.
When a run-time error is detected in a script, execution is halted and no further attempts to execute the script are made. Run-time errors may also be generated via the function RO_Error.
When a script is found to contain an error, a message of the format 'JS error in RunTime.Context: Script: FileSpec, line n: ErrorMessage' is issued. Where:
For example: 'JS error in scripts.PreTxn: Script: <EnBank$Dir>.data.JS.PreTxn, line 1: ReferenceError: date is not defined'.
Certain errors, such as syntax errors, can include additional information to help in debugging scripts. If this is the case, the error window will include a Detail button which loads the error log into your text editor.