User manual

256
mikoC PRO for dsPIC
MikroElektronika
Jump Statements
The jump statement, when executed, transfers control unconditionally. There are four such statements in the mikroC
PRO for dsPIC30/33 and PIC24:
- break
- continue
- goto
- return
Break and Continue Statements
Break Statement
Sometimes it is necessary to stop the loop within its body. Use the break statement within loops to pass control to the
rst statement following the innermost switch, for, while, or do block.
Break is commonly used in the switch statements to stop its execution upon the rst positive match. For example:
switch (state) {
case 0: Lo(); break;
case 1: Mid(); break;
case 2: Hi(); break;
default: Message(“Invalid state!”);
}
Continue Statement
The continue statement within loops is used to “skip the cycle”. It passes control to the end of the innermost enclosing
end brace belonging to a looping construct. At that point the loop continuation condition is re-evaluated. This means
that continue demands the next iteration if the loop continuation condition is true.
Specically, the continue statement within the loop will jump to the marked position as it is shown below:
while (..) {
...
if (val>0) continue;
...
// continue jumps here
}
do {
...
if (val>0) continue;
...
// continue jumps here
while (..);
for (..;..;..) {
...
if (val>0) continue;
...
// continue jumps here
}