|
<< 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.Get
Gets the value at a specific index from the array.
Intention
The ARS.Get command retrieves the value at the specified index from the array. This is useful for accessing specific elements within the array.
Illustration:
📦 Array: [1, 2, 3, 4, 5]
🔢 Index to get: 2
🔑 Handle: $$ARR
🔑 Value at index: 2
🔑 Result stored in $$VAL
Syntax
ARS.Get|$$ARR|$$INDEX[|$$VAL]
Parameter Explanation
P1 - $$ARR - (Variable)
The handle of the array from which to get the value.
P2 - $$INDEX - (Variable)
The index of the value to be retrieved from the array.
P3 - $$VAL (optional) - (Variable)
The variable to store the retrieved value. If omitted, the value is placed on the Top of Stack (TOS).
Example
'***********************************
' ARS.Get - 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.Get|$$ARR|2|$$VAL
DBP.New Value at index 2: $$VAL
ARR.End|$$ARR
'
'***********************************
' ARS.Get - 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.Get|$$ARR|3
DBP.New Value at index 3 on TOS
ARR.End|$$ARR
'
'***********************************
' ARS.Get - 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.Get|$$ARR|1|$$VAL
DBP.New Value at index 1: $$VAL
ARR.End|$$ARR
'
Remarks
-
Limitations:
-
See also:
•