HP Pascal/iX Reference Manual (31502-90022)

2-: 6
Example
GOOD_TIME_9 { These identifiers }
good_time_9 { are }
gOOd_TIme_9 { equivalent. }
x2_GO
a_long_identifier
Boolean { Standard identifier.}
Scope
The
scope
of an identifier is its domain of accessibility or the region
of a program in which it may be used. In general, a user-defined
identifier can appear anywhere in a block after its definition.
Furthermore, the identifier can appear in a block nested within the block
in which it is defined.
If an identifier is redefined in a nested block, however, this new
definition takes precedence in the entire block. The object defined at
the outer level is no longer accessible from the inner level. Once
defined at a particular level, an identifier may not be redefined at the
same level, except for field names.
Labels are not identifiers, and their scope is restricted. They cannot
mark statements in blocks nested within the block where they are
declared.
Identifiers defined at the main program level are
global
. Identifiers
defined in a function or procedure block are
local
to the function or
procedure. The definition of an identifier must precede its use, with
the exception of pointer type identifiers, program parameters, predefined
identifiers, and forward declared procedures or functions.
For a module, identifiers declared in the EXPORT section are valid for
the entire module. Identifiers declared after the IMPLEMENT keyword are
valid only within the IMPLEMENT part of the module.
When a module is imported, the identifiers in the EXPORT section of the
imported module are placed in the
global scope
of the program. Because
of this, the identifiers in the EXPORT section must be unique not only
within the module, but also within the
global scope
of a program.
Example
PROGRAM show_scope (output);
CONST
asterisk = '*';
VAR
x: char; {global variable}