Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
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 repeat block).
For example:
Lcd_Out(1,1,'Insert CF card');
// Wait for CF card to be plugged; refresh every second
while TRUE do
begin
if Cf_Detect() = 1 then break;
Delay_ms(1000);
end;
// 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 for loop moves program counter to the line with keyword for 
continue
statement in while loop moves program counter to the line with loop con
dition (top of the loop), 
continue
statement in repeat loop moves program counter to the line with loop 
condition (bottom of the loop). 
// continue jumps here
for i := ... do
begin
...
continue;
...
end;
// continue jumps here
while condition do
begin
...
continue;
...
end;
172
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5