../pvss.htm menu.gif basics.gif

Debugging a script

Normally scripts execute in fractions of a second, so it is often impossible to stop a script quickly enough after starting it with a click. You can set a break point, however. If you then run the script again it will execute up to the first break point that you have set. Using the Step button you can then let execution continue step by step.

Having selected a script or a thread, you can then retrieve various information, or execute the script step by step.   

IconHow to work with threads or scripts

 

In the following example you will use the cyclic script of the example panel examples/trend. Copy the panel into your project directory. Open the panel in the Vision module and click on Start. Random numbers are sent to the data point ExampleDP_Trend1 and displayed in a trend diagram.

1. Open the CTRL Debugger for the manager UI_1 (if your UI has the number 1).

2. Click on the ScriptID or the thread number of the trend panel

3. Click on Break to pause the script/thread. The Info window displays the line number at which the script was interrupted. Execution of the script is stopped. The trend continues as a straight line.  

4. Click on Continue to resume execution. The trend once again receives random values and produces a corresponding trace.

5. Click on Break again and then Step to run through the script instruction by instruction. The line number is again displayed in the Info window. The scripts contain a while loop, which is now being executed step by step: first step line 28, next step line 29, line 30 and so on.

 

IconHow set/remove a breakpoint

You can set breakpoints in order to interrupt execution of a script at specific points:

 

1. Click on the required line in the left-hand column of the Source window to set a breakpoint at this position.

2. The breakpoint is indicated by a red star.  

3. Execution of the script is halted BEFORE execution of the first instruction of the selected line.

4. To remove a breakpoint, simply click on the breakpoint again in the Source window.   

 
  • In multi-line commands set the breakpoint in the last line

  • In void functions set a breakpoint wherever you want execution to stop

Setting breakpoints does not work in functions with return values.

 

Select "Other Info/Breakpoints" to see all the breakpoints that have been set.

IconInformation about a thread

1. Click on "Info Thread" to display the current local variables and other information on the selected thread.

2. The information displayed might look as follows:

ThreadId: 1
next work: 1970.01.01 01:00:00.000
local variables:
int n = 0
string userBit = ""
dyn_string names = <...> 3 items

Information

Meaning

ThreadId

shows the current thread number

next work

indicates when the CTRL Interpreter is to handle this thread again (the date above means immediately)

local variables

a list of the local variables is given underneath with the data type and value

int n = 0

integer variable

string userbit = ""

string variable, variable contents of type "string" are always enclosed in inverted commas.

dyn_string names = <..> 3 items

For dyn_ data types only the number of elements is displayed. To display the contents of these you can double-click on the line containing the dyn_variable. For example the information displayed in the Info window for this dyn_string might be:

1: "Start"
2: "Stop"
3: "Filter"

 

IconHow to set variables

During debugging it is possible to set different variable values in order to modify or test execution in step mode.

 

caution.gifCaution

These variables are actually set in the manager that is running. Therefore, if the user does not take steps to prevent it, a value will also be sent to the actual process.

1. Enter a command with the following syntax in the command line:

 

set <variable_name> <value>

 

2. For instance entering "set n 5" sets the variable "n" to the value 5.

 

note.gifNote

Elements with a field or array data type (dyn/dyn_dyn) cannot be set manually in the Debugger.

IconHow to obtain further information

Click on the Other Info button and select one of the options.

You will be given a list of possible information. The response to each query appears in the Info window. Some of these options can also be chosen using the buttons (see CTRL Debugger panel).

Information

Meaning

Libs

Displays all CTRL libraries that are loaded

Globals

Displays all global variables for that manager

Breakpoints

Displays all the breakpoints that have been set

Script Modules

Displays information on active script modules such as timedFunc(), operatingHours() etc. Script modules run in the background as CTRL modules rather like a "compiled thread". These are functions that are started from the CTRL manager.   

Connections

Displays information on dpConnect(), alertConnect() or queryConnect() for the current script.

 

Top Of Page

 

V 3.11 SP1

Copyright ETM professional control GmbH 2013 All Rights Reserved