User manual

196
mikoBasic PRO for PIC32
MikroElektronika
Labels
Labels serve as targets for goto and gosub statements. Mark the desired statement with label and colon like this:
label_identier : statement
No special declaration of label is necessary in mikroBasic PRO for PIC32.
Name of the label needs to be a valid identier. The labeled statement and goto/gosub statement must belong to
the same block. Hence it is not possible to jump into or out of routine. Do not mark more than one statement in a block
with the same label.
Note:
- The label main marks the entry point of a program and must be present in the main module of every project. See
Program Organization for more information.
- Label should be followed by end of line (CR) otherwise compiler will report an error.
Here is an example of an innite loop that calls the procedure Beep repeatedly:
loop:
Beep
goto loop
Symbols
mikroBasic PRO for PIC32 symbols allow you to create simple macros without parameters. You can replace any line of
code with a single identier alias. Symbols, when properly used, can increase code legibility and reusability.
Symbols need to be declared at the very beginning of the module, right after the module name and (optional) include
clauses. Check Program Organization for more details. Scope of a symbol is always limited to the le in which it has
been declared.
Symbol is declared as:
symbol alias = code
Here, alias must be a valid identier which you will use throughout the code. This identier has a le scope. The code
can be any line of code (literals, assignments, function calls, etc).
Using a symbol in the program consumes no RAM – the compiler will simply replace each instance of a symbol with the
appropriate line of code from the declaration.
Here is an example:
symbol MAXALLOWED = 216 ‘ Symbol as alias for numeric value
symbol PORT = PORTC ‘ Symbol as alias for SFR
symbol MYDELAY = Delay_ms(1000) ‘ Symbol as alias for procedure call
dim cnt as byteSome variable