Labels
Labels serve as targets for goto statements. Mark the desired statement with a label and colon like this:
label_identifier : statement
Before marking a statement, you must declare a label. Labels are declared in declaration part of unit or routine, similar to variables and constants. Declare labels using the keyword label
:
label label1, ..., labeln;
Name of the label needs to be a valid identifier. The label declaration, marked statement, and goto
statement must belong to the same block. Hence it is not possible to jump into or out of a procedure or function. Do not mark more than one statement in a block with the same label.
Here is an example of an infinite loop that calls the Beep
procedure repeatedly:
label loop; ... loop: Beep; goto loop;

label loop; ... loop: Beep; // compiler will report an error loop: // compiler will report an error
Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
What do you think about this topic ? Send us feedback!