Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 728 of 909
Each SWITCH control block must have at least one CASE number defined plus one, and only
one, ENDS statement. SWITCH is not a valid terminal command — it is only valid within a user
program.
EXAMPLE:
Consider the following code fragment:
SWITCH v
CASE 1
PRINT(" v = 1 ",#13)
BREAK
CASE 2
PRINT(" v = 2 ",#13)
BREAK
CASE 3
PRINT(" v = -23 ",#13)
BREAK
DEFAULT
PRINT("v IS NOT 1, 2 OR -23",#13)
BREAK
ENDS
The first line, SWITCH v, lets the SmartMotor™ know that it is checking the value of the
variable v. Each following CASE begins the section of code that tells the SmartMotor what to
do if v is equal to that case.
EXAMPLE:
a=-3 'Assign a value
WHILE a<4
PRINT(#13,"a=",a," ")
SWITCH a 'Test the value
CASE 3
PRINT("MAX VALUE",#13)
BREAK
CASE -1 'Negative test values are valid
CASE -2 'Note no BREAK here
CASE -3
PRINT("NEGATIVE")
BREAK 'Note use of BREAK
CASE 0 'Zero test value is valid
PRINT("ZERO") 'Note order is random
DEFAULT 'The default case
PRINT("NO MATCH VALUE")
BREAK
ENDS 'Need not be numerical
a=a+1
LOOP
END
Part 2: Commands: SWITCH formula