Contents | Prev | Next
7.4.37 The pack procedure
Description
The pack procedure assigns values to all the elements of a packed array by copying
some or all of the elements of an unpacked array into the packed array. The elements of both
arrays must have the same type.
Parameter
- The first parameter is a reference to the unpacked
array variable that contains the array elements to copy.
- The second 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 from). The elements
from the start element of the unpacked array to the last element of the unpacked array are
available to be copied into the packed array. It is an
error if the number of elements in the unpacked array
available to be copied into the packed array is less then the number of elements in the packed
array, since values must be copied to all the elements in the packed array. NOTE:
This parameter must be assignment compatible with
the index type of the unpacked array.
- The third parameter is a reference to the packed
array variable that contains the array elements to be copied
into.
Example
Suppose you have the following arrays
p : packed array[21..23] of integer;
u : array[1..10] of integer;
then
pack(u, 1, p)
copies elements 1 to 3 of u into elements 21 to 23 of p.
And
pack(u, 5, p)
copies elements 5 to 7 of u into elements 21 to 23 of p
pack(u, 9, p)
is an error because only two elements of u (i.e. 9 and 10) are available to
be copied but p has three elements.
Portability
Operating Systems: All
Standard Pascal: Yes
Contents | Prev | Next