<< Click to Display Table of Contents >> Navigation: 3. Script Language > Variable Definitions and Operations > Array -Commands > Array -Commands |
MiniRobotLanguage (MRL)
ARR.Set INT Array
Set Array Element to Integer Value (64 bit signed)
Intention
The ARR.Set INT Array command is designed to set the value of a specific element in a specified 64-bit integer array.
This is useful for populating arrays with numerical data, particularly when only integer values are needed and 8 bytes of storage are available for each element.
•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) should be a 64-bit integer, requiring 8 bytes of storage.
•Default Value: If P3 is omitted, the element at the specified index will be cleared (set to zero).
•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.
•Use Formulas in (): if you want to use Formulas put them in ().
•Initialize Arrays with multiple Values separated with ",": You can initialize Arrays with multiple values like this:
' Here we will fill the subsequent Elements 1,2 and 3
ARR.Sin|0|1|10,12,($$NUA*4)
Syntax
ARR.Set INT Array|P1|P2[|P3]
ARR.Sin|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 you specify multiple Elements in P3, then P2 is the Start-Index.
•P3 - Value (Optional): Specifies the 64-bit integer value to set for the element at the given index. If omitted, the element will be cleared (set to zero).
You can also specify multiple value, separated using "," to fill following Array-Elements:
$$ELE=10,12,($$NUA*4),56,78,(99*4)
ARR.Sin|0|1|$$ELE
Speed in Ticks:
Example
'***********************************
' ARR.-Sample for setting a 64-bit integer array element
'***********************************
' Sets the 10th element of 64-bit Integer Array 5 to the maximum 64-bit integer value
ARR.Set INT Array|5|10|9223372036854775807
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