P
ar
t
2: C
omman
d
s
Moog Animatics SmartMotor™ Developer's Guide, Rev. L
Page 727 of 909
SWITCH formula
Switch, Program Flow Control
APPLICATION:
Program execution and flow control
DESCRIPTION:
Multiple choice branch for program execution
EXECUTION:
Immediate
CONDITIONAL TO:
N/A
LIMITATIONS:
Can only be executed from within user program
REPORT VALUE:
N/A
WRITE:
N/A
LANGUAGE ACCESS:
N/A
UNITS:
N/A
RANGE OF VALUES:
N/A
TYPICAL VALUES:
N/A
DEFAULT VALUE:
N/A
FIRMWARE VERSION:
5.x and later
COMBITRONIC:
N/A
DETAILED DESCRIPTION:
The SWITCH command allows program flow control based on specific integer values of a
formula, a specific parameter or a variable.
The execution time is similar to the equivalent IF formula control block. Therefore, placing the
most likely CASE values at the top of the CASE list will yield faster program execution times.
At execution time, the program interpreter evaluates the SWITCH formula value and then
tests the CASE numbers for an equal value in the programmed order.
l
If the SWITCH formula value does equal the CASE number, then program execution
continues with the command immediately after.
l
If the SWITCH formula value does not equal the CASE number, then the next CASE
statement is evaluated.
l
If the SWITCH formula value does not equal any CASE number, then the DEFAULT entry
point is used.
l
If the SWITCH formula value does not equal any CASE number and there is no DEFAULT
case, then program execution passes through the SWITCH to the ENDS without
performing any commands.
If a BREAK is encountered, then program execution branches to the instruction or label
following the ENDS of the SWITCH control block. BREAK can be used to isolate CASEs. Without
BREAK, the CASE number syntax is transparent and program execution continues at the next
instruction. That is, you will run into the next CASE number code sequence.
Part 2: Commands: SWITCH formula