Function AClone() Foundation

Creates a complete copy of a single or multi-dimensional array().

AClone( <aArray> ) --> aClonedArray
<aArray> is the array which is completely copied.

The return value of AClone() is a duplicate of <aArray>.


The array function AClone() is used to create copies of multi-dimensional arrays. Since the function ACopy() only copies the elements in the first dimension of an array and does not consider subarrays, it cannot be used to copy a multi-dimensional array. AClone(), on the other hand, also creates copies of subarrays if array references are contained in the elements of <aArray>.

Comparison between ACopy() and AClone()

// In the example, an array is created which contains a subarray 
// in its second element. A copy of the array is then made 
// using ACopy() and AClone(). When copied using ACopy(), 
// the second element of both the original array and the copy 
// reference the same array. The copy made with AClone(), however, 
// contains a duplicate array as the second element. 

   LOCAL aArray , aClone, aCopy 

   aArray := {"A", ; 
             {"B1","B2","B3"}, ;       // subarray in second element 
              "C", ; 
              "D" } 

   aClone := AClone( aArray )          // create complete copy 

   aCopy  := ACopy( aArray, Array(4) ) // only first dimension 
                                       // is copied 

   ? aCopy [2][1] := "Xbase++"         // result: Xbase++ 
   ? aClone[2][1]                      // result: B1 
   ? aArray[2][1]                      // result: Xbase++ 



If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.