User guide
39
VTB USER GUIDE
9 INSTRUCTIONS TO CONTROL THE PROGRAM FLOW
In VTB there are a lot of instruction to control the program flow. They are similar to other compiler and THEY ARE
AVAILABLE IN ALL THE HARDWARE TYPES.
9.1 IF-ELSE-ENDIF
Allow the conditional execution of a group of instruction according to the result of an expression.
Syntax
If condition
[instruction]
Else
[instructionelse]
endif
The syntax of instruction if... else is composed by the following elements:
condition Mandatory. Any expression with the result True (value not zero) or False (value zero).
instruction List of the instruction to execute if the condition IF is TRUE.
instructionelse Optional. List of the instruction to execute if the condition IF is FALSE.
endif End of cycle IF ELSE
Notes
The instruction Select Case can be more useful when there are a lot of continuous cycles IF because it creates a source
code more readable.
Example
Used variables:
var1 int
var2 int
if var1*var2 > 120
var1=0
else
var1=120
endif
9.2 LABEL
Identifies a reference point for the GOSUB or GOTO jumps.
Syntax
Label labelname
labelname name of the reference of the LABEL.
In each PAGE or MAIN task it can not exist more LABEL with the same name.
WARNING: The LABEL instruction is OBSOLETE. It is preferred to use the FUNCTIONS.
Example
if condiition
goto label1
else
goto label2
endif
.