P
ar
t
2: C
omman
d
s
Moog Animatics SmartMotor™ Developer's Guide, Rev. L
Page 421 of 909
ELSE
IF-Structure Command Flow Element
APPLICATION:
Program execution and flow control
DESCRIPTION:
Alternate action of IF
formula
or ELSEIF
formula
within
IF...ELSE...ENDIF control block
EXECUTION:
Immediate
CONDITIONAL TO:
Value of previous IF
formula
or ELSEIF
formula
.
LIMITATIONS:
Must reside with IF
formula
...ENDIF program control block; can
be executed only from within a user program
READ/REPORT:
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:
An IF formula...ENDIF control block may optionally include an ELSE statement to control
execution when none of the test conditions are true. As illustrated in the following example,
an IF formula can be used when you want the SmartMotor™ to do one thing if the variable
g=43 and another if it does not equal that value.
EXAMPLE:
IF
g==43
("Gee...43!",#13)
ELSE
("No 43 for me.",#13)
ENDIF
The first line checks to see if g is equal to 43. If so, the string "Gee...43!" is sent out the
primary serial port. The ELSE in line 3 tells the SmartMotor what to do otherwise.
An IF control block can have only one ELSE statement. When the language interpreter
evaluates the IF formula as false (zero), an ELSE exists and there are no ELSEIF statements,
the program branches immediately to the statement following the ELSE. If there are ELSEIF
formula clauses within the control block, all the ELSEIF clauses must precede the ELSE clause.
In these cases, the ELSE clause is only executed when both the IF formula is false (zero) and
all ELSEIF formulas are false (zero).
ELSE is analogous to the DEFAULT case for a SWITCH control block.
ELSE is not a valid terminal command; it is only valid within a user program.
Part 2: Commands: ELSE