Basic Micro Studio Syntax Manual
Basic Micro Studio Syntax Manual
Basic Micro Studio Syntax Manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
REPEAT - UNTIL<br />
<strong>Syntax</strong><br />
repeat<br />
program statements<br />
until condition<br />
• Statements - any group of commands to be run inside the loop.<br />
• Condition - can be a variable or expression<br />
Supported<br />
• BA - Supported<br />
• BAN - Supported<br />
• BAP - Supported<br />
• BAP40 - Supported<br />
Commands<br />
Description<br />
The REPEAT - UNTIL loop executes commands nested inside of it until some condition is false. This<br />
is the opposite of DO - WHILE and WHILE - WEND. The condition can be any variable or expression<br />
and is tested every loop until true.<br />
Notes<br />
1. In the programming world 0 is considered false. By default REPEAT - UNTIL will test this condition.<br />
If a stand alone variable is used for the test, the loop will continue until it’s value NOT equal to 0.<br />
2. WHILE - WEND checks the condition fi rst. If the condition is false the WHILE - WEND statements<br />
and all program code nested within them will not run.<br />
3. You can nest multiple REPEAT - UNTIL commands within each other. You can nest DO - WHILE or<br />
WHILE - WEND loops within a REPEAT - UNTIL loop.<br />
Example<br />
Connect to the following program with the terminal window set to 9600 baud. The program will start<br />
counting up from 0 to 100. Once the index reaches a value of 101, the condition is no longer false.<br />
The greater than symbol (>) was used for the condition and 101 is now greater than 100 making the<br />
condition true. Since REPEAT - UNTIL loops while a statement is false the program will now exit.<br />
;ALL - all_repeat_until.bas<br />
Index var word<br />
Main<br />
End<br />
Index = 0<br />
Repeat<br />
index = index + 1<br />
;lets print the value index<br />
serout s_out, i9600,[0, “Couting: “, dec index]<br />
pause 75<br />
Until index > 100 ;run until index is greater than 100<br />
serout s_out, i9600, [13,13, “Index = “, dec index]<br />
serout s_out, i9600, [13, “My condition is no longer false.”]<br />
serout s_out, i9600, [13, “Index is now greater than 100”]<br />
171