HP Pascal/iX Reference Manual (31502-90022)

5:- 9
subsequent use in the definitions of other types. In the only exception
to this rule, a base type identifier in a pointer type definition is
allowed before the base type is defined. However, the base type must be
defined before the end of the TYPE section in which it is first
mentioned.
TYPE
This reserved word delimits the start of the
type
declarations in a
program, module, procedure, or function. A type definition establishes
an identifier known as
type identifier
as a synonym for a
data type
. The
identifier may then appear in subsequent type or constant definitions or
in variable declarations.
The reserved word TYPE precedes one or more type definitions. A
type
definition
consists of an identifier, the equals sign (=), and a type.
A
data type
determines a set of attributes that includes the following:
* The set of permissible values.
* The set of permissible operations.
* The amount of storage required.
The three most general categories of data type are
simple
,
structured
,
and
pointer
.
Simple data types are the types
ordinal
,
real
, or
longreal
. Ordinal
types include the standard types
integer
,
char
,
bit16
,
bit32
,
bit52
,
shortint
,
longint
, and
boolean
as well as user-defined
enumerated
and
subrange
types.
Structured data types are the types
array, record, set,
and
file
. The
standard type
string
is also a structured data type. The standard type
text
is a variant of the file type.
Pointer data types define pointer
variables
that point to dynamically
allocated variables on the heap. For a detailed description of HP Pascal
data types, refer to Chapter 3 .
CONST, TYPE, VAR, MODULE, and IMPORT sections may be intermixed.
Syntax
Type_decl:
.
Example
TYPE
units = (inches,feet,miles); { Simple type }
files = ARRAY [1..10] OF text; { Structured type }
PTR1 = ^units; { Pointer type }
Variable Declaration
A
variable declaration
introduces an identifier as a variable of a
specified type. Each variable is a statically-declared object that
occupies storage and is accessible for the activation and duration of the
program, procedure, or function in which it is declared.
Components of a structured variable may be accessed using an appropriate
selector. Pointer variable dereferencing accesses dynamic variables on
the heap. Module variables are accessible for the duration of the