The unpack procedure
Description
The unpack procedure assigns values to some or all of the elements of an
unpacked array by copying all of the elements of a packed array into the unpacked array.
The elements of both arrays must have the same type.
Parameter
- The first parameter is a reference to the packed
array variable that contains the array elements to copy.
- The second parameter is a reference to the unpacked
array variable that contains the array elements to be copied
into.
- The third parameter is an expression of
ordinal type that specifies the start element of the
unpacked array (i.e. the element of the unpacked array to
start copying to). All of the elements of the unpacked array from the start element to the end
are available to be copied into. It is an error if the
number of elements in the unpacked array available to be copied into is less then the number
of elements in the packed array, since all the elements in the packed array are copied.
NOTE: This parameter must be
assignment compatible with the index type of
the unpacked array.
Example
Suppose you have the following arrays
p : packed array[21..23] of integer;
u : array[51..60] of integer;
then
unpack(p, u, 51)
copies elements 21 to 23 of p into elements 51 to 53 of u.
and
unpack(p, u, 57)
copies elements 21 to 23 of p into elements 57 to 59 of u.
and
unpack(p, u, 59)
produces an error since only two elements (i.e. 59 and 60) of u are available to
be copied into but all three elements of p must be copied.
Portability
Operating Systems: All
Standard Pascal: Yes