Switch..case—program branching – HEIDENHAIN SW 54843x-02 DIN Programming User Manual
Page 401

HEIDENHAIN MANUALplus 620, CNC PILOT 640
401
4.32 Conditional bloc
k r
u
n
SWITCH..CASE—program branching
The switch statement consists of the elements:
SWITCH, followed by a variable. The content of the variable is
interrogated in the following CASE statement.
CASE x: The CASE branch is run with the variable value x. CASE can
be programmed repeated times.
DEFAULT: This branch is executed if no CASE statement matched
the variable value. DEFAULT can be omitted.
BREAK: Concludes the CASE branch or DEFAULT branch.
Programming:
Select "Extras > DINplus word...". The control opens the "Insert DIN
PLUS word" selection list.
Select SWITCH.
Enter the switch variable.
For each CASE branch:
Select CASE (in "Extras > DINplus word..."). )
Enter the SWITCH condition (value of the variable) and
insert the NC blocks to be executed.
For the DEFAULT branch: Insert the NC blocks to be executed.
Example: SWITCH..CASE
. . .
N.. SWITCH #g201
N..
CASE 1
[executed if #g201=1]
Executed if #g201=1
N.. G0
Xi10
. . .
N..
BREAK
N..
CASE 2
[executed if #g201=2]
Executed if #g201=2
N.. G0
Xi20
. . .
N..
BREAK
N..
DEFAULT
No CASE statement matched the variable value
N.. G0
Xi30
. . .
N..
BREAK
N..
ENDSWITCH
. . .