Adding, Editing and Deleting Scripts
Scripts are added, edited and compiled in the System > Scripts context.
Adding a Script
To create a new script:
- In the Scripts context Action pane, select the Insert action ( ) . This opens the Insert Script dialog, which collects the necessary information and creates a new script with it.
- Enter a name for the new script.
- In the Source property, click the ellipsis to open the Script Source Code dialog and enter the source directly into the window.
- Click the Validate
Script button to test the script. The script validation
results are displayed.
- If there were any compilation errors, edit the script.
- If the script compiled successfully, click OK.
The new script is inserted into the Pharos Database.
Once the script has been added, it must then be attached to the relevant Pharos component as a plug-in. Scripted plug-ins are attached to:
Deleting a Script
To delete an existing script, select a script and click the Delete option on the Scripts context Action pane ( ).
Editing Scripts
To change a script's name, type a new entry into the Name field.
To edit a script, click the editing button at the end of the Source field. This opens the Script Source window:
Make any changes to the source in the main window, then click OK to save the changes. Before saving it is a good idea to click the Validate Script button to test that the script compiles successfully.
Testing Compilation
If an error occurs when a script is compiled, the Source Code window jumps to the line of the error, and reports in the Validation Results field:
For example, the following invalid code:
// source code example
// these lines are comments
error = ;
// wrong!, should be "error = 1;" or similar
would produce the following error report:
‘A parse error at line 3: ";" has occurred in the Script. Please fix this’
This means that a syntactic error was encountered at line 3, and the compiler became confused when it reached the semicolon (';') on that line. The Script Code Source Window will jump to this line so you can inspect the code to find the error. This is a ‘compile-time’ error, and even if the script compiles successfully, there may still be errors in the code that are not revealed until it is run (a ‘run-time’ error). Scripting errors generated at this point are found in Pharos Alert Codes, numbers 28300 - 28330.
When a run-time error occurs in a scripted plug-in, the line number reported is that of the first line of the erroneous statement. This means that the actual error in the script may have occurred on a later line, if the statement spans multiple lines.