Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 424 of 909
If the associated formula is true, then the following clause is executed until an ELSEIF, ELSE
or ENDIF is encountered, and then execution branches to the ENDIF of the current IF control
block. If the first ELSEIF clause is not executed, then program execution continues at the next
ELSEIF formula, and so on, until all the ELSEIF formulas have been tested. In the case all
ELSEIFs have false formulas and an ELSE clause exists, that clause will be executed.
The ELSEIF statement is similar to the CASE number in a SWITCH control block. Note the
difference—ELSEIF handles formulas, but CASE only handles a fixed number.
ELSEIF is not a valid terminal command. It is only valid within a user program.
EXAMPLE:
a=3 'Will be found false
IF a==2
PRINT("222")
ELSEIF a==3'Will be found true
PRINT("333")'so "333" will be printed.
ENDIF
EXAMPLE:
IF a==1 'Only if a is NOT 1, 2, or 3
'will GOSUB5 be executed.
GOSUB2
ELSEIF a==2
GOSUB3
ELSEIF a==3
GOSUB4
ELSE
GOSUB5
ENDIF
RELATED COMMANDS:
ELSE IF-Structure Command Flow Element (see page 421)
ENDIF End IF Statement (see page 433)
IF formula Conditional Program Code Execution (see page 475)
Part 2: Commands: ELSEIF formula