Click or drag to resize

AClone Function (Array)

X#
Duplicate a multidimensional array.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION AClone(
	aSource AS ARRAY
) AS ARRAY
Request Example View Source

Parameters

aSource
Type: Array
The array to duplicate.

Return Value

Type: Array
A duplicate of aSource.
Remarks
AClone() creates a complete duplicate of aSource.
If aSource contains subarrays, AClone() creates matching subarrays and fills them with copies of the values in the aSource subarrays.
To copy subarrays by reference instead of creating new ones, use ACloneShallow().
Examples
This example creates an array, then duplicates it using AClone().
The first array is then altered, but the duplicate copy is unaffected:
X#
1LOCAL aOne, aTwo AS ARRAY
2aOne := {1, 2, 3}            // aOne is {1, 2, 3}
3aTwo := AClone(aOne)            // aTwo is {1, 2, 3}
4aOne[1] := 99                // aOne is {99, 2, 3}
5                        // but aTwo is still {1,2,3}
See Also