JavaScript Component
Properties Methods Events Configuration Settings Errors
The JavaScript component allows quick and simple evaluation of JavaScript source code.
Syntax
nsoftware.InScript.Javascript
Remarks
The JavaScript component allows quick and simple evaluation of JavaScript source code. JavaScript code can be evaluated from a file or simply from a string that holds valid JavaScript.
Prior to calling Eval or EvalFile any custom functions must be added by calling AddFunction. At the time of execution when the function is called the Function event will fire. Within this event the Parameters property may be queried to obtain information about the function parameters. Calculate the and provide the return value within Function.
The AddVariable method may also be used to add a variable to the running context.
To execute the JavaScript code call Eval or EvalFile. The output is returned by these methods. If any errors occur during processing the Error event will fire.
The component relies on an external engine to execute the JavaScript code. Several common engines are shipped with the toolkit. The Engine property specifies which engine will be used.
Engine Notes
The component uses a common interface which acts as a bridge between the component itself and the actual engine. The component will make calls to the interface library which will in turn make calls to the selected engine. Every project must include the interface library, as well as the selected engine library.
The interface library is a separate file: "nsoftware.InScript.Interface.dll" (.NET) or "inscript.interface.jar" (Java). This file must be included in your project.
In addition to the interface library, the actual engine must be present. Several engine libraries are shipped with the product in the "lib" folder. The engines do not need to be included in your project, but must be present at runtime in order to be loaded by the interface library.
Windows Engines
The component supports two different JavaScript engines: The V8 JavaScript engine from Google and the Jurassic engine. Possible values for this property are:
- jurassicengine.dll (.NET Edition Only)
- v8engine.dll (default)
Java Engines
The component supports the Rhino JavaScript engine. Possible values for this property are:
- rhinoengine.jar (default)
Eval Notes
When calling Eval or EvalFile any custom functions must first be defined by calling AddFunction. When the function is encountered the Function event will fire. Within this event query the Parameters collection to get the function parameter values. The return value of the custom function is defined within the Function event.
Any errors such as undefined functions or other issue will cause the Error event. Errors will not cause an exception. It is important to monitor the Error event for information about any errors that occur.
The return value from Eval or EvalFile is the output from successful execution of the JavaScript.
Property List
The following is the full list of the properties of the component with short descriptions. Click on the links for further details.
Engine | Indicates the active JavaScript engine. |
EvalFrame | Indicates the current frame of the JavaScript source code. |
Parameters | A collection of function parameters when custom function is invoked. |
Method List
The following is the full list of the methods of the component with short descriptions. Click on the links for further details.
AddFunction | Adds a custom function. |
AddVariable | Adds a variable to running context. |
Close | Closes the JavaScript context. |
Config | Sets or retrieves a configuration setting . |
Eval | Executes the specified JavaScript source code. |
EvalFile | Executes the specified JavaScript source file. |
GC | Performs garbage collection. |
Interrupt | Terminates the running JavaScript execution. |
Event List
The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.
Error | Information about errors during data delivery. |
Function | Fired when a custom function is called. |
Configuration Settings
The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.
EngineName | The name of internal JavaScript engine. |
EngineVersion | The version of internal JavaScript engine. |
CodePage | The system code page used for Unicode to Multibyte translations. |