User Manual

MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
167
There is no limit to how many ELSEIF statements you can have in any single IF...THEN block. The
following program shows an example using multiple ELSEIF statements.
value var long
value = 0
main
if value = 0 then
value = 1
elseif value = 1
value = 2
elseif value = 2
value = 3
elseif value = 3
value = 4
elseif value = 10
value = 0
endif
;display the value on the PC terminal window
puts 0,["Value=",dec value,13]
pause 1000
goto main
ELSE
In previous examples we tested several conditions that were determined as being false, which
would cause the program will resume normal operation, skipping any code found enclosed
within the IF..THEN / ENDIF statements unless an ELSE statement was added. The ELSE block
will execute when everything else was FALSE. The following program was written to be followed
using a terminal window connected at 9600 baud. See if you can you guess the results?
value var long
value = 0
main
if value = 1 then
value = 1
elseif value = 2
value = 2
else
value = 3
endif
;display the value on the PC terminal window
serout s_out,i9600,[“Value=”,dec value,13]
pause 1000
goto main