|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > ARS. - Array's > !ARS. - Array Operations > ARS. - Array Operations |
MiniRobotLanguage (MRL)
ARS.Insert
Inserts a value at a specific index in the array.
Intention
The ARS.Ins command inserts a value at the specified index in the array. This is useful for adding elements at specific positions within the array.
Illustration:
📦 Original Array: [1, 2, 3, 4, 5]
🔢 Index to insert: 2
🔢 Value to insert: 99
📦 Modified Array: [1, 2, 99, 3, 4, 5]
🔑 Handle: $$ARR
Syntax
ARS.Insert|$$ARR|$$IND|$$VAL
Parameter Explanation
P1 - $$ARR - (Variable)
The handle of the array into which to insert the value.
P2 - $$IND - (Variable)
The index at which to insert the value.
P3 - $$VAL - (Variable)
The value to insert into the array.
Example
'***********************************
' ARS.Ins - Sample 1
'***********************************
ARS.New|$$ARR
ARS.Add|$$ARR|1
ARS.Add|$$ARR|2
ARS.Add|$$ARR|3
ARS.Add|$$ARR|4
ARS.Add|$$ARR|5
ARS.Ins|$$ARR|2|99
DBP.New Array after insertion: [1, 2, 99, 3, 4, 5]
ARR.End|$$ARR
'
'***********************************
' ARS.Ins - Sample 2
'***********************************
ARS.New|$$ARR|i
ARS.Add|$$ARR|100
ARS.Add|$$ARR|200
ARS.Add|$$ARR|300
ARS.Add|$$ARR|400
ARS.Add|$$ARR|500
ARS.Ins|$$ARR|3|999
DBP.New Array after insertion: [100, 200, 300, 999, 400, 500]
ARR.End|$$ARR
'
'***********************************
' ARS.Ins - Sample 3
'***********************************
ARS.New|$$ARR|f
ARS.Add|$$ARR|1.1
ARS.Add|$$ARR|2.2
ARS.Add|$$ARR|3.3
ARS.Add|$$ARR|4.4
ARS.Add|$$ARR|5.5
ARS.Ins|$$ARR|1|9.9
DBP.New Array after insertion: [1.1, 9.9, 2.2, 3.3, 4.4, 5.5]
ARR.End|$$ARR
'
Remarks
-
Limitations:
-
See also:
•