How to debug Reliance scripts with an external debugger

August 1, 2010

Requirements

To debug scripts, a Just-In-Time debugger is required. A very simple one is Microsoft Script Debugger, which is available to download from the Microsoft's website. If you want a more comfortable and powerful debugger, you can use Visual Studio Community, which is free of charge for non-commercial purposes. You can install both debuggers and decide which one to use just before the actual debugging.

In addition, you need to use Reliance 4.1.3 or later.

Enabling debugging through the Reliance Design development environment

To enable the debugging of scripts, activate the Enable script debugging with external tool (Just-In-Time debugger) option through the Environment Options dialog of Reliance Design (Tools > Environment Options > Script Debugging).

Environment Options – Enable script debugging with external tool (Just-In-Time debugger)

Environment Options – Enable script debugging with external tool (Just-In-Time debugger)

Launching a debugger

If debugging is enabled and there's a Just-In-Time debugger installed, the debugger is automatically invoked in the following cases:

  • If an error occurs in a script.
  • If the Stop statement is executed in a script.

Afterward, you can immediately debug the script that has invoked the debugger.

Example

The following instructions show how to debug a script on a practical example.

  1. In the Reliance Design development environment, create a new project and a new script with the following program code:
  2. Option Explicit
    Dim nIndex, nCounter
    Stop
    For nIndex = 1 To 100
    nCounter = nCounter + 1
    Next
  3. Place a Button component on a visualization window and link it to the above script.
  4. Start the project.
  5. Click the button to run the script. When the Stop statement is executed, the debugger should be invoked. If there are multiple debuggers installed on the computer, a dialog box is displayed that prompts you to choose the preferred debugger from a list.
  6. For the purpose of this example, choose Microsoft Script Debugger

    For the purpose of this example, choose Microsoft Script Debugger.

  7. When the debugger is launched, it automatically displays the program code of the debugged script and the line containing the Stop statement is marked with a yellow color.
  8. Microsoft Script Debugger
  9. Place the cursor on the 5th line and set a breakpoint on it using the Toggle BreakPoint command.
  10. Microsoft Script Debugger
  11. Run the interrupted script using the Run command. The execution will stop on the breakpoint line.
  12. Programový kód
  13. Now it is possible to examine or change the value of any variable through a command window that can be displayed by choosing the Command Window command. To examine the value of the variable nIndex, type: ? nIndex
  14. Programový kód

    To change the value of the variable nIndex to 30, type: nIndex=30

Warning

  • The Enable script debugging with external tool (Just-In-Time debugger) option affects all programs installed on the computer. As a result, a Just-In-Time debugger can also be invoked by a program other than Reliance.
  • When a script is being debugged, all other scripts belonging to the same thread of execution are blocked. Therefore, it is strongly recommended that you disable the debugging of scripts when running a Reliance project on the end-user's computer (in a production environment). Beginning with Reliance 4.1.3, a system message is periodically generated to inform the user that the debugging of scripts is enabled.
Bulb, icon

Tip:

Haven't found what you were looking for? Use this form to inform us about it.

Related links


Example projects

Technical articles

Video tutorials

Try the Reliance SCADA system right now!

Try the Reliance SCADA/HMI system on several sample visualizations.

Try the Reliance SCADA/HMI system on several sample visualizations or download the trial version installer to your computer for free.

Try the Reliance SCADA system right now Try the Reliance SCADA system right now Try the Reliance SCADA system right now