366 ISO Programming
4.32 Conditional Block Run
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:
U Select “Extras > DINplus word...”. The MANUALplus opens the
“Insert DIN PLUS word” selection list.
U Select SWITCH.
U Enter the switch variable.
U 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.
U 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
. . .