Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 475 of 909
IF formula
Conditional Program Code Execution
APPLICATION: Program execution and flow control
DESCRIPTION: IF formula...ENDIF control block
EXECUTION: Immediate
CONDITIONAL TO: Value of formula after the IF statement
LIMITATIONS: Requires corresponding ENDIF; can be executed only from
within 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
DETAILED DESCRIPTION:
CAUTION: Extensive use of IF statements and GOTO branches can quickly
make your programs impossible to read or debug. Learn to organize your code
with one main loop using a GOTO and write the rest of the program with
subroutines (GOSUB). For details, see GOSUB(label) on page 463.
The IF statement provides a method for an executing program to choose between alternate
execution paths at runtime. In its simplest form, the IF control block consists of:
IF (formula) 'Evaluates as nonzero
'Run the code below the "IF" command
ENDIF
NOTE: Every IF structure must be terminated with an ENDIF.
Formula is a test condition — both mathematical comparisons and Boolean-logic bitwise
comparisons can be used.
l
If the result of the formula is any value besides 0, then it is considered true and the
code immediately following the IF formula statement is executed.
l
If the result of formula is 0, then it is considered false and execution skips the code
following IF formula. When false, execution skips to the next available ELSE, ELSEIF or
ENDIF command.
The following table shows various forms of IFformulas and their descriptions:
Part 2: Commands: IF formula