SWITCH branching

SWITCH branching permits the processing of various NC program variants as a function of an arithmetic expression.

The control statements given below are used

$SWITCH, $CASE, $DEFAULT, $ENDSWITCH

for branching.

Branching always starts with:

$SWITCH <expr1>

followed by several

$CASE <expr2>

...

$BREAK

optionally followed by:

$DEFAULT

and always ends with

$ENDSWITCH

Programing Example

prg_example

SWITCH branching

N100 $SWITCH P1=INT [P1*P2/P3] If the result of the arithmetic expression

                               is equal to 1, the blocks after $CASE 1 are

N110 $CASE 1                   executed (N120-140)

N120 ...

N130

N140 $BREAK

N150 $CASE P2                  If the result is equal to P2, the blocks
                               N160..N170 are executed.

N160 ...

N170 $BREAK

N300 $CASE n

N320 ...

N330 $BREAK

N350 $DEFAULT                  The $DEFAULT block is optional and serves to
                               process the NC blocks N360-N380.

N360 ...                       if the result of the $SWITCH block

N370                           does not match any of the $CASE cases.

N380

N390 $ENDSWITCH

Notice

notice

The expression <expr1> and <expr2> are compared using the internal REAL mode. Here, both expressions are evaluated as equal if the value difference is < 0.001.

The expressions <expr1> and <expr2> can also assume negative values.