HP Pascal/iX Reference Manual (31502-90022)

9- 16
Description
This procedure transfers data from a packed array to an unpacked array.
For example, assuming that a is an ARRAY[m..n] OF t and
z
is a PACKED
ARRAY [u..v] OF t; the procedure unpack
(z,a,i)
successively assigns the
components of the packed array z, starting at component u, to the
components of the unpacked array
a
, starting at
a [ i ]
.
All the components of
z
are assigned. Also, the normalized value of
i
must be less than or equal to the difference between the lengths of
a
and
z
+ 1; for example,
i
-m+1 <= (n-m) - (v-u) + 1. Otherwise, it is an
error when unpack attempts to index
a
beyond its upper bound.
The index types of
a
and
z
need not be compatible. The components of the
two arrays, however, must be type identical.
The call unpack
(z,a,i)
is equivalent to:
BEGIN
k:= i;
FOR j:= u TO v DO
BEGIN
a[k]:= z[j];
IF j <> v THEN k:= succ(k);
END;
END;
where k and j are variables that are type compatible with the indices of
a
and
z
respectively.
Example
PROGRAM show_unpack (input,output);
TYPE
suit_types = (casual, business, leisure, birthday);
VAR
suit : PACKED ARRAY [1..5] OF suit_types;
kase : ARRAY [1..10] OF suit_types;
i : integer;
.
.
BEGIN
.
.
i := 1;
unpack(suit,kase,i); { After execution, the first 5 }
. { components of kase contain the }
. { value of suit. }
.
i := 7
unpack(suit,kase,i); { An error results because unpack }
. { attempts to assign a component of }
. { suit to a component of kase which }
. { is out of range. }
END.
Program Control Procedures
The only
program control procedures
supported by HP Pascal are halt and
assert. The details of these procedures are given below.
halt
Usage