Program structures, 1 if ... else ... endi structure, 17 program structures – HEIDENHAIN TNC 306 Technical Manual User Manual
Page 399
![background image](/files/815307/content/doc399.png)
3/2000
TNC 416/TNC 406/TNC 306
Commands
7-109
3.17 Program Structures
A program is split up into program sequences so as to make it clearer. To do this the programmer
uses jump labels (LBL) and conditional and unconditional jumps.
When structured instructions are used, the jump labels and jump commands are created by the
Compiler. Remember that internal jump labels are generated to implement these structured
commands, so the total number of available jump labels will be reduced accordingly. Structured
instructions can be nested to up to 16 levels but there must be no "interleaving".
Right:
IFT
Wrong: IFT
...
...
WHILEF
WHILEF
...
...
ENDW
END
...
...
ENDI
ENDW
Instructions IFT, IFF, WHILET, WHILEF, ENDW, UNTILT and UNTILF require a valid gating result in
the Logic Accumulator. They terminate the gating chain. Instructions ELSE, ENDI and REPEAT
require all gating chains to be terminated first.
3.17.1 IF ... ELSE ... ENDI Structure
The IF ... ELSE ... ENDI structure permits the alternative processing of two program branches
depending on the value in the Logic Accumulator. The ELSE branch can be omitted. The following
commands are available:
•
IFT
(If Logic Accu True)
Following code only if Logic Accumulator=1
•
IFF
(If Logic Accu False)
Following code only if Logic Accumulator=0
•
ELSE
(else)
Following code only if IF not fulfilled
•
ENDI
(End of IF-Structure)
End of IF Structure
Example:
L
I0
IFT
;If Logic Accu=1
....
;Program code for I0 = 1
ELSE
;
can be omitted
....
;Program code for I0 = 0
can be omitted
ENDI
;end of conditional processing