CArray:Copy
The Copy method duplicates the current CArray and returns the new object.
A = CArray:Copy() |
A is a new CArray containing the same values as the current one. In place of CArray, use the name of the actual object to be copied (see Remarks).
This method copies an existing CArray and returns a reference to the new CArray. You cannot copy a CArray or other class object using the trivial statement B = A, as this simply makes the value of B a reference to the object A. In other words, B becomes an alias to A. To get around this, two copy methods are provided by the CArray class:
To create a CArray that is a copy of the current object, use the Copy method. This creates a new CArray B before duplicating the values of the current object A. For example,
B = A:Copy() |
-- CArray A already exists |
To create a new CArray that is a copy of an existing object, use the copy constructor, as in
B = new_array(A) |
-- CArray A already exists |
You can use the copying syntax that fits best with your script.
The following script duplicates the CArray A into a new CArray A2:
|
-- create a CArray |
|
-- set member 1 |
|
-- set member 40 |
|
-- creates a duplicate CArray A2 |
|
-- result: N = 2 |
|
-- if finished with A, clean up memory |
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.