As an example of using JScript in Axxon PSIM, try to create a script for containing an error and then correct it. The script performs the following tasksactions: when Macro 1 starts, set the value 10 to the "Hot Recordingrecord" time parameter for Cameras № 1 – 4 cameras 1–4 and output the "Hello world message " message to the debugger debugging window of the Editor-Debugger utility.
...
- In the Hardware tab of the System Settings window window, create four Camera objects with identification numbers 1, 2, 3, and 4 , if they have not been created before.
- In the Programming tab, create a Macro object with identification number 1. The Don't fill in the Events table should not be filled for .for the correct execution of the following actions and successful run of the script.
- In the Programming tab, create a Script system object. Give the object Create a Script object in the Programming tab. Enter the identification number 1 and the name "Script 1".
- In On the settings panel of the Script 1 object settings panel, select select Always in from the Time zone schedule drop-down list.
- Click the Editor-Debugger button at the bottom of the settings panel of the Script 1 settings panel system object. The The Editor-Debugger utility window will openopens.
- In the Editor-Debugger utility window, open the Script Debug/Edit-edit script list and select the Script 2 object.
Image Modified Enter In the following in the Script field, enter the following:
Code Block |
---|
|
if (Event.SourceType == "MACRO" && Event.SourceId == "1" &&
Event.Action == "RUN")
{
var ;
for(i=1; i<=4; i=i+1)
{
SetObjectParam("CAM",i,"hot_rec_time","10");
}
DebugLogString ("Hello world");
} |
Note |
---|
|
The script contains an error. See below the recommendations on how to fix it. |
- In the File menu, select Save to database to save the script.
- Create a test event to run the script in debug mode – “MACRO—MACRO|1|RUN|”. To achieve this, in the Debug and edit menu, select Edit test event; the . The Test message window will openopens. Fill in the fields in the the Test message window as shown in the figure.

- To run the script with the test event, select Test run in the Debug and edit menu.
- Open the Script Messages list and select Script 1. The debugger window will open at debugging window opens on the right side.
- In the debugger debugging window, find the “Process Event:MACRO|1|RUN|” line and the following error message: “Src identifier missing: Microsoft JScript compilation error Line:2 Char:6 Error:0 Scode:800a03f2”.
Image Modified
The error message says that there is no identifier in the second line of variable declaration operator (var). That This means that no variable has been declared. This is a critical error in JScript, thus the script has not been executed.
Change Correct the text of the script (see the “var i;” line).
Code Block |
---|
|
if (Event.SourceType == "MACRO" && Event.SourceId &&
Event.Action == "RUN")
{
var i;
for(i=1; i<=4; i=i+1)
{
SetObjectParam("CAM",i,"hot_rec_time","10");
}
DebugLogString ("Hello world");
} |
- In the File menu, select Save to database to save the script.
- Repeat steps 10 and 11.
- In the debugger debugging window, find the “Process Event:MACRO|1|RUN|” line and the “DebugLogString:Hello world” and “Script first run OK” messages. The “Script first run OK” means that the script runs correctly in the debug mode.

- Close the Editor-Debugger utility.
- The text of the created script will be shown displayed in the Script field field of the Script 1 system object settings panel. Click the Apply button in on the settings panel of the Script 1 settings panel system object to activate the script.
- Select Macro 1 in the Run menu of the main control panel.
- In the debugger debugging window of the Axxon PSIM system, check that the macro and the script have run successfully.
Image Modified Check the accuracy of the script result. The Hot recording field "Hot record" time field in the Camera 1 to Camera 4 object objects settings panels should read “10”must have the 10 value.

Info |
---|
|
The"Hot recording record" time field in the Camera settings panel is empty by defaultof the Camera objects is blank by default. By default, the new script is unavailable for all computers in the distributed system. To make it available, you must set the 0 value for the key ScriptSlavesDefaultNotSelected of the HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\AxxonSoft\AxxonPSIM registry (see Registry keys reference guide. For the information on working with the registry, see Working with Windows OS registry). |
Script creation and debugging is now complete.