Copies one or more elements in an array to a new array.
|
COPYARRAY(NewArray, Array, Position[, Length])
|
Parameters
- NewArray
-
Type: Array
The array to copy to; the destination array.
- Array
-
Type: Array
The array to copy from; the source array.
- Position
-
Type: Integer
The position of the first array element to copy.
- Length
-
Type: Integer
The number of array elements to copy. If you do not specify
Length, all array elements are
copied from Position to the last
element. Use this equation to determine valid values:
1 =< LENGTH =< MAXLEN(ARRAY) - POSITION + 1
Remarks
Example
If array1 is an integer array with dimension 10, and it
contains the numbers from 1 to 10, the following command copies the
numbers 6,7,8,9,10 to array2, an integer array with dimension
5.
|
Copy Code |
COPYARRAY (array2,array1,6,5);
|
If array1 is an integer array with dimension 10, and it
contains the numbers from 1 to 10, the following command copies the
numbers 6,7,8,9,10 to array2, an integer array with dimension 5. In
this example the length parameter has been omitted.
|
Copy Code |
COPYARRAY (array2,array1,6);
|
The effect would be exactly the same as the first
example because in this example, the default copying of everything
from position 6 and forward from array1 just happens to fit in
array2, which has a dimension of 5.
If array1 is an integer array with dimension 10, and it
contains the numbers from 1 to 10, and array2 is an integer array
with dimension 5, the following command causes a run-time
error.
|
Copy Code |
COPYARRAY (array2,array1,3);
|
This example causes a run-time error because seven
elements would be copied from array1 to array2 and array2 has only
room for five.
See Also