6.2.6.1   Control

Synopsis:
Select control flow operators.

Here, you may select control structures for the program. This involves the execution of a program segment (henceforth named body) depending on a test (if, elseif) or comparison (switch, case, and endswitch) and the repetition of a program segment (for, while, and repeat) with controlled loop execution (break, continue). Exception handling is implemented with try, catch, and endtry along with throw for user-defined exceptions. Furthermore, you may stop the program's execution at any position (stop) or terminate HDevelop (exit). The operators assign and insert do not influence the execution, but serve to specify values for control data (assignment). The operator comment is used to add a comment, that means any sequence of characters, to the program. Using the operator export_def, you can enter special comments that will get uncommented when you export the HDevelop program to another programming language. This way, arbitrary code may be embedded into HDevelop programs. See page 968 for more information. The operator return terminates the current procedure call and returns to the calling procedure (see section “Creating Procedures” on page 318 for more information about HDevelop procedures).

Selecting a menu item displays the corresponding control construct in the operator window, where you can set the necessary parameters. After specifying all parameters you may transfer the construct into your program. A direct execution for loops and conditions is not possible, in contrast to other HDevelop and HALCON operators, because you have to specify the loop's and condition's body first to obtain useful semantics. If necessary, you may execute the program after the input with Step Over or Run. The IC is positioned after the construct head to ensure the input of the construct's body occurs in the correct place. This body is indented to make the nesting level of the control constructs visible, and thus to help you in understanding the program structure. The semantics for loops and conditions are shown in section “Control Flow Operators” on page 879.

Assignment The operator assign serves as an assignment operator for control variables (numbers, strings and handles). Analogously to “normal” operators the input is made in the operator window by specifying both “parameters” Input and Result (i.e., right and left side of the assignment). An instruction in C, e.g.,

  x = y + z;

is declared inside the operator window as

  assign(y + z,x)

and displayed in the program window by

  x := y + z

The operator insert implements the assignment of a single value (tuple of length 1) at a specified index position of a tuple. Thus, an array assignment (here in C syntax)

  a[i] = v;

is entered as

  insert(a,v,i,a)

in the operator window, and is displayed as

  a[i] := v

in the HDevelop program window.

Program termination The operators stop and exit are used to terminate the program. More precisely, stop interrupts an execution and exit terminates HDevelop. Having interrupted the execution you may continue the program by pressing Step Over or Run. This is useful, e.g., in demo programs to install defined positions for program interruption. Under Linux, you can use exit in combination with a startup file and the command line switch -run. Thus, HDevelop will not only load and run your application automatically, but also terminate when reaching exit.

Comments

The operator comment allows you to add a line of text to the program. This text has no effect on the execution of the program. A comment may contain any sequence of characters.