User Manual
MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
177
REPEAT...UNTIL
Syntax
repeat
program statements
until condition
• Statements - any group of commands to be run inside the loop.
• Condition - can be a variable or expression
Description
The REPEAT - UNTIL loop executes commands nested inside of it until some condition is false.
This is the opposite of DO - WHILE and WHILE - WEND. The condition can be any variable or
expression and is tested every loop until true.
Notes
The loop will continue until it’s value is NOT equal to 0. REPEAT - UNTIL checks the condition at
the end of the loop. This means the loop will always execute atleast once. You can nest multiple
REPEAT - UNTIL commands within each other. You can nest DO - WHILE or WHILE - WEND loops
within a REPEAT - UNTIL loop.
Example
The program will start counting up from 0 to 100. Once the index reaches a value of 101, the
condition is no longer false. The greater than symbol (>) was used for the condition and 101 is
now greater than 100 making the condition true. Since REPEAT - UNTIL loops while a statement
is false the program will now exit.
;ALL - all_repeat_until.bas
Index var word
Main
Index = 0
Repeat
index = index + 1
;lets print the value index
puts 0,[0, “Couting: “, dec index]
pause 75
Until index > 100 ;run until index is greater than 100
puts 0, [13,13, “Index = “, dec index]
puts 0, [13, “My condition is no longer false.”]
puts 0, [13, “Index is now greater than 100”]
End