As an example of using JScript in Axxon PSIM, try to create a script containing an error and then correct it. The script performs the following actions: when Macro 1 starts, set the value 10 to the "Hot record" time parameter for cameras 1–4 and output the "Hello world" message to the debugging window of the Editor-Debugger utility.
To create and run this script, do the following:
- In the Hardware tab of the System Settings dialog 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. Don't fill in the Events table 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 the identification number 1 and the name "Script 1".
- On the settings panel of the Script 1 object, select Always from the Time schedule drop-down list.
- Click the Editor-Debugger button at the bottom of the settings panel of the Script 1 system object. The Editor-Debugger utility window will open.
- In the Editor-Debugger utility window, open the Debug-edit script list and select the Script 2 object.

In the Script field, enter the following:
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");
}
- In the File menu, select Save to database to save the script.
- Create a test event to run the script in debug mode—MACRO|1|RUN|. To achieve this, in the Debug and edit menu, select Edit test event. The Test message window will open. Fill in the fields in the Test message window as shown in 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 debugging window will open on the right side.
- In the 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”.

The error message says that there is no identifier in the second line of variable declaration operator (var). This means that no variable has been declared. This is a critical error in JScript, thus the script has not been executed.
Correct the text of the script (see the “var i;” line).
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 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 displayed in the field of the Script 1 system object. Click the Apply button on the settings panel of the Script 1 system object to activate the script.
- Select Macro 1 in the Run menu of the main control panel.
- In the debugging window of Axxon PSIM, check that the macro and the script have run successfully.

Check the accuracy of the script result. The "Hot record" time field in the Camera 1 to Camera 4 objects settings panels must have the 10 value.

Script creation and debugging is now complete.