mikroC

mikroC - C Compiler for Microchip PIC microcontrollers

making it simple...

Jump Statements

A jump statement, when executed, transfers control unconditionally. There are four such statements in mikroC: break, continue, goto, and return.

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 switch, for, while, or do block.

Break is commonly used in switch statements to stop its execution upon the first positive match. For example:

page

122

switch (state) {

case 0: Lo(); break;

case 1: Mid(); break;

case 2: Hi(); break;

default: Message("Invalid state!");

}

Continue Statement

You can use the continue statement within loops (while, do, for) 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-evaluat- ed. This means that continue demands the next iteration if loop continuation condition is true.

Goto Statement

Use the goto statement to unconditionally jump to a local label — for more information on labels, refer to Labeled Statements. Syntax of goto statement is:

goto label_identifier;

This will transfer control to the location of a local label specified by

label_identifier. The label_identifier has to be a name of the label within the same function in which the goto statement is. The goto line can come before or after the label.

MikroElektronika: Development tools - Books - Compilers