Documentation for Intellect 4.9.8. Documentation for other versions of Intellect is available too.

Skip to end of metadata
Go to start of metadata

As an example of using JScript in Intellect, try to create a script for the following tasks: when Macro 1 starts, set the value 10 to the Hot Recording parameter for Cameras  № 1 – 4 and output the Hello world message to the debugger window of the Editor-Debugger utility.

To create and run this script, do the following:

  1. In the Hardware tab of the System Settings window, create four Camera objects with identification numbers 1, 2, 3 and 4, if they have not been created before.
  2. In the Programming tab, create a Macro object with identification number 1. The Events table should not be filled for .
  3. Create a Script object in the Programming tab. Enter the identification number 1 and the name Script 1.
  4. In the Script 1 object settings panel, select Always in the Time zone list.
  5. Click the Editor-Debugger button at the bottom of the Script 1 settings panel. The Editor-Debugger window will open.
  6. In the Editor-Debugger window, open the Script Debug/Edit list and select the Script 2 object.
  7. Enter the following in the Script field:

     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");
    }
  8. In the File menu, select Save to database to save the script.
  9. 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.
  10. To run the script with the test event, select Test run in the Debug and edit menu.
  11. Open the Script Messages list and select Script 1. The debugger window will open at the right side.
  12. In the debugger 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). That means no variable has been declared. This is a critical error in JScript, thus the script has not been executed.

  13. Change 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");
    }
  14. In the File menu, select Save to database to save the script.
  15. Repeat steps 10 and 11.
  16. In the debugger 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.
  17. Close the Editor-Debugger utility.
  18. The text of the created script will be shown in the Script field of the Script 1 object settings panel. Click the Apply button in the Script 1 settings panel to activate the script.
  19. Select Macro 1 in the Run menu of the main control panel.
  20. In the debugger window of the Intellect system, check that the macro and the script have run successfully.
  21. Check the accuracy of the script result. The Hot recording field in the Camera 1 to Camera 4 object settings panels should read “10”.

    Note

    The Hot recording field in the Camera settings panel is empty by default

Script creation and debugging is now complete.