Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 476 of 909
IF
formula
Description
IF a==b if a equals b
IF a!=b if a does not equal b
IF a<b if a is less than b
IF a<=b if a is less than or equal to b
IF a>b if a is greater than b
IF a>=b if a is greater than or equal to b
IF a&b if a AND b (bitwise comparison)
IF a|b if a OR b (bitwise comparison)
IF a if a does not equal zero (common shortcut to IF a==1)
The formula after the IF statement may:
l
Include Combitronic values retrieved from other motors
l
Consist of multiple variables and math operators
Note that there isn't a logical OR, AND or XOR. The bitwise operators may be used with proper
attention paid to the result of those operations. For example:
IF (a==b)|(c==d)
will be true if a equals b, OR if c equals d. The reason this works is that comparison operators
such as "==" return 0 if false and 1 if true. In a bitwise sense, this is setting bit 0 when true.
The bitwise OR operator "|" compares all bits. However, only the lowest bit becomes
significant.
EXAMPLE: (If true, run some code.)
IF PA>12345 'If Position is above 12345
PRINT("position is greater than 12345",#13)
ENDIF 'This is the next line of code to be executed
'whether it is true or not.
EXAMPLE: (If true, run some code; ELSE if false, run some other code.)
IF PA>12345 'If Position is above 12345
PRINT("position is greater than 12345",#13)
ELSE 'If it is no true
PRINT("position is not greater than 12345",#13)
ENDIF 'This is the next line of code to be executed
EXAMPLE: (If true, run some code; else if something else is true, run that code.)
IF PA>12345 'If Position is above 12345
PRINT("position is greater than 12345",#13)
ELSEIF PA==0 'If Position equals zero
PRINT("position is at zero",#13)
ENDIF 'This is the next line of code to be executed
'even if position is not at zero and
'not greater than 12345.
Part 2: Commands: IF formula