<RetVar> = clone array <Var/Array>: index <Var/Number> ... <Var/Number>

X2:The ThreatX3:Reunion
Use this command to copy an array, or part of an array.

You cannot copy an array simply by doing $array1 = $array2 because the variable $array1 is simply a pointer to the array. what you would end up with is two variable pointing to the same array. You could change the value of element 2 on $array2 and it would have changed for $array1 as well.

To make a copy so that you can modify only one of the arrays, you need to use this command.

example

$array1 = array alloc: size= 5
$array2 = clone array $array1: index 0 ... 5


It is NOT necessary to "array alloc" $array2 first.

Clone creates a new array $array2 and copies the first 6 elements of $array1 into $array2.

The high index value is capped at the highest index in $array1.
$array1 = array alloc: size= 5
$array2 = clone array $array1: index 0 ... 50

has the exact same effect, creating an $array2 with 6 elements.

Changing the values in $array2 now has no effect on $array1.

boron