|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > ARS. - Array's > !ARS. - Array Sorting > ARS. - Array Operations |
MiniRobotLanguage (MRL)
ARS.Copy
Copies content from one array to another, overwriting existing content.
Intention
The ARS.Copy command duplicates the entire contents of a source array ($$ARR) into a target array ($$ARB), replacing whatever was in $$ARB before.
This is a fast way to transfer data between arrays without manually looping through elements.
Both arrays can be of any type—Integer, FP (Floating Point), or String—and the copy preserves the source array’s type and order.
If the size of the target Array is too small it will be re-dimmed.
Unlike with ARS.Clone, the target Array must exist to use ARS.Copy!
Illustration:
📦 Source Array ($$ARR): [1, 2, 3]
📥 Target Array Before ($$ARB): [4, 5]
🔄 Target Array After Copy: [1, 2, 3]
Syntax
ARS.Copy|$$ARR|$$ARB
Parameter Explanation
P1 - $$ARR - (Variable)
The handle of the source array to copy from.
P2 - $$ARB - (Variable)
The handle of the target array to copy to, overwriting its existing contents.
Example
'***********************************
' ARS.Copy - Sample 1
'***********************************
ARS.New|$$ARR|i
ARS.New|$$ARB|f
ARS.Add|$$ARR|1
ARS.Add|$$ARR|2
ARS.Add|$$ARR|3
ARS.Add|$$ARB|4
ARS.Add|$$ARB|5
ARS.Copy|$$ARR|$$ARB
DBP.Copied array $$ARB: [1, 2, 3]
ARS.End|$$ARR
ARS.End|$$ARB
'
Remarks
- The source array $$ARR remains unchanged after the copy.
- The target array $$ARB adopts the type and content of $$ARR.
Limitations:
- Both arrays must be valid and initialized.
See also:
• ARS.New
• ARS.Add