User manual
198
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Constants
Constant is a data whose value cannot be changed during the runtime. Using a constant in a program consumes no
RAM memory. Constants can be used in any expression, but cannot be assigned a new value.
Constants are declared in the declaration part of a program or routine. You can declare any number of constants after
the keyword const:
const constant_name [: type] = value;
Every constant is declared under unique constant_name which must be a valid identier. It is a tradition to write
constant names in uppercase. Constant requires you to specify value, which is a literal appropriate for the given type.
type is optional and in the absence of type, the compiler assumes the “smallest” of all types that can accommodate
value.
Note: You cannot omit type when declaring a constant array.
Pascal allows shorthand syntax with only one keyword const followed by multiple constant declarations. Here’s an
example:
const
MAX : longint = 10000;
MIN = 1000; // compiler will assume word type
SWITCH = ‘n’; // compiler will assume char type
MSG = ‘Hello’; // compiler will assume string type
MONTHS : array[1..12] of byte = (31,28,31,30,31,30,31,31,30,31,30,31);
Labels
Labels serve as targets for goto statements. Mark the desired statement with a label and colon like this:
label_identier : 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 identier. 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 innite loop that calls the Beep procedure repeatedly:
label loop;
...
loop:
Beep;
goto loop;