<< Click to Display Table of Contents >> Navigation: 3. Script Language > Variable Definitions and Operations > Array -Commands > Array -Commands |
MiniRobotLanguage (MRL)
ARR.Set Array
Set Array Element to String Content
Intention
The ARR.Set command is designed to set the value of a specific element in a specified array.
This is useful for populating arrays with data or updating existing elements:
•Element Update: The command sets the value of the element at the specified index (P2) in the specified array (P1).
•Data Types: The value (P3) can be a string or a binary string.
•Default Value: If P3 is omitted, the element at the specified index will be cleared (set to an empty string).
•Auto-Dim: if you specify an Index that is "Out of range" (higher then dimensioned), then the engine will increase the dimension of the Array automatically to that size.
Syntax
ARR.Set Array|P1|P2[|P3]
ARR.Set|P1|P2[|P3]
Parameter Explanation
•P1 - Array Number: Specifies the array number, which can range from 0 to 32.
•P2 - Array Index: Specifies the index of the element within the array that you want to set. If the Index is larger then the currently reserved number of Elements the Smart Package Robot will automatically try to Re-Dim the Array, this not influence Elements in the Array.
•P3 - Value (Optional): Specifies the value to set for the element at the given index. This can be a string or a binary string. If omitted, the Array element with that number P2 will be cleared (set to an empty string).
Speed in Ticks:
Example
'***********************************
' ARR.-Sample for setting an array element
'***********************************
' Sets the 10th element of Array 5 to "Hello"
ARR.Set|5|10|Hello
END.
Remarks
Inside the code, all Datatypes are stored "as String". Means, technically also the INT-Arrays and the FP-Arrays are String-Arrays.
Therefore you can use
' Fill Element 0 of Array Nr.1 with the INT-Value of "42" which is stored as an 8-Byte String (64-Bit)
' Set Array with an 64-bit signed Integer Value
ARR.Set INT Array|1|0|42
' Return Array Content as String
ARR.Get|1|0|$$RET
' This will return an Binary value that defines the 64-bit Signed-Integer value for "42"
MBX.$$RET
Therefore, if you know what you are doing, you can theoretically fill all even Array-Elements with INT Values,
and put in all odd Array-Values Strings (what ever). You can mix the Datatypes as long as you know what is in where.
You can also use another Array to index what Datatype is in which Array-Element and this way construct a mix of Elements.
Limitations:
-
See also:
• VAR. - Variable Set Value/Clear
• VAV. - Variables with Variables
• VBA. - Variable Binary Append
• CAL. - mathematical CALculation
See also:
•SDO.Arr----Small-Introduction-To-A
•Unpack-Array-from-File_Delimiter
•Unpack-Array-from-Var_Delimiiter