Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 191 of 909
GOTO(label) and GOSUB(label) may be used where label can be a variable, a specific number
or a single operand such as a+b, x-5, etc.
NOTE: Nested parenthesis are not permitted—for example, GOTO(IN(3)).
WHILE 1
x=IN(W,0,15) 'precalculate to prevent parenthesis in GOSUB()
IF y!=x
y=x
GOSUB(15-x) 'simple single operand math only
ENDIF
LOOP
SWITCH, CASE, BREAK, ENDS Examples
The following code shows the proper use of the SWITCH, CASE, BREAK and ENDS commands.
For more details on these commands, see SWITCH, CASE, DEFAULT, BREAK, ENDS on page
186.
C500
#define FiveValues INA(V1,3)/1000
#define CheckPot 501
WHILE 1
IF x!=FiveValues
GOSUB(CheckPot)
ENDIF
LOOP
RETURN
C501 'CheckPot (Check Potentiometer)
y=FiveValues
SWITCH FiveValues
CASE 0 PRINT("Value ",y,#13) BREAK 'Note: Defines not allowed in PRINTs
CASE 1 PRINT("Value ",y,#13) BREAK
CASE 2 PRINT("Value ",y,#13) BREAK
CASE 3 PRINT("Value ",y,#13) BREAK
CASE 4 PRINT("Value ",y,#13) BREAK
ENDS
x=FiveValues
RETURN
Part 1: Programming: SWITCH, CASE, BREAK, ENDS Examples