User manual
mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
193
Visibility
The visibility of an identier is that region of the program source code from which legal access to the identier’s
associated object can be made.
Scope and visibility usually coincide, though there are circumstances under which an object becomes temporarily
hidden by the appearance of a duplicate identier, i.e. the object still exists but the original identier cannot be used to
access it until the scope of the duplicate identier is ended.
Technically, visibility cannot exceed scope, but scope can exceed visibility.
Name Spaces
Name space is a scope within which an identier must be unique. The mikroPascal PRO for dsPIC30/33 and PIC24
uses two distinct categories of identiers:
1. Global variables are visible throughout the whole unit, from the place of declaration. Also. they can be
seen in other units, if they are declared above the Implementation section.
2. Local variables, parameters, types, function results - must be unique within the block in which they are
declared.
For example:
var level : byte;
procedure control(sens : byte);
var location : byte;
begin
location := 1;
sens := location;
level := 123;
end;
procedure temperature;
begin
location := 0; // ILLEGAL
sens := 23; // ILLEGAL: redenition of sens
level := 95;
end;
Place of declaration Scope
Identier is declared in the declaration of a pro-
gram, function, or procedure
Scope extends from the point where it is declared to the end of the current
block, including all blocks enclosed within that scope. Identiers in the out-
ermost scope (le scope) of the main unit are referred to as globals, while
other identiers are locals.
IIdentier is declared in the interface section of a
unit
Scope extends the interface section of a unit from the point where it is
declared to the end of the unit, and to any other unit or program that uses
that unit.
Identier is declared in the implementation section
of a unit, but not within the block of any function or
procedure
Scope extends from the point where it is declared to the end of the unit.
The identier is available to any function or procedure in the unit.