Техническая Спецификация для Mikroelektronika MIKROE-350
BREAK AND CONTINUE STATEMENTS
Break Statement
Sometimes, you might need to stop the loop from within its body. Use the break
statement within loops to pass control to the first statement following the innermost
loop (for, while, or do).
statement within loops to pass control to the first statement following the innermost
loop (for, while, or do).
For example:
Lcd_Out(1, 1, "No card inserted")
' Wait for CF card to be plugged; refresh every second
while true
while true
if Cf_Detect() = 1
then
break
end if
Delay_ms(1000)
Delay_ms(1000)
wend
' Now we can work with CF card ...
Lcd_Out(1, 1, "Card detected ")
Continue Statement
You can use the
continue
statement within loops to “skip the cycle”:
-
continue
statement in the
for
loop moves program counter to the line with
keyword for
-
continue
statement in the
while
loop moves program counter to the line with loop
condition (top of the loop),
-
continue
statement in the
do
loop moves program counter to the line with loop
condition (bottom of the loop).
159
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5
' continue jumps
here
for i = ...
here
for i = ...
...
continue
...
continue
...
next i
' continue jumps
here
while condition
here
while condition
...
continue
...
continue
...
wend
do
...
continue
...
continue
...
' continue jumps
here
loop until condition
loop until condition