ACopy Function | |
Copy elements from one array to another.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION ACopy(
aSource,
aTarget,
nStart,
nCount,
nTargetPos
) AS ARRAY CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static Array ACopy(
Usual aSource = default,
Usual aTarget = default,
Usual nStart = default,
Usual nCount = default,
Usual nTargetPos = default
)
Request Example
View SourceParameters
- aSource (Optional)
- Type: Usual
The array to copy elements from. - aTarget (Optional)
- Type: Usual
The array to copy elements to. - nStart (Optional)
- Type: Usual
The starting element position in aSource.
A negative value starts from the end.
If nCount is positive, the default value is 1; if nCount is negative, the default value is the length of the array.
- nCount (Optional)
- Type: Usual
The number of elements to copy from aSource, beginning at nStart.
A negative value starts from the end.
If nCount is not specified, all elements in aSource beginning with the starting element are copied.
- nTargetPos (Optional)
- Type: Usual
The starting element position in aTarget to receive elements from aSource.
The default value is 1.
Return Value
Type:
Array
A reference to
aTarget.
Remarks
ACopy() copies elements from aSource to aTarget.
aTarget must already exist and be large enough to hold the copied elements.
If aSource has more elements, some elements will not be copied.
ACopy() copies values of all data types.
If an element of aSource is a subarray, the corresponding element in aTarget will contain only a reference to the subarray.
Thus, ACopy() will not create a complete duplicate of a multidimensional array.
To do this, use the AClone() function.
Examples
This example creates two arrays, each filled with a value.
The first two elements from the source array are then copied into the target array:
1LOCAL nCount := 2, nStart := 1, aOne, aTwo
2aOne := {1, 1, 1}
3aTwo := {2, 2, 2}
4ACopy(aOne, aTwo, nStart, nCount)
5
This example copies an array in reverse order into another array:
1FUNCTION Start()
2 LOCAL a1, a2 AS ARRAY
3 a1 := {1, 2, 3, 4, 5}
4 a2: = ArrayCreate(ALen(a1))
5
6 ACopy(a1, a2, -1, - 0xFFFF, 1)
See Also