<< Click to Display Table of Contents >> Navigation: 3. Script Language > Variable Definitions and Operations > Array -Commands > Array -Commands |
MiniRobotLanguage (MRL)
ARR.Set FP Array
Set Array Element to Floating Point Value
Intention
The ARR.Set FP Array command is designed to set the value of a specific element in a specified floating-point array.
This is useful for populating arrays with numerical data, particularly when high precision is required.
•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 an extended-precision floating-point number, offering 18 digits of precision and requiring 10 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.
•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.Sfp|0|1|1.0,1.2,($$NUA*4.45)
Syntax
ARR.Set FP Array|P1|P2[|P3]
ARR.SFP|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=1.0,1.2,($$NUA*4),56.5,78.56,(99.34*4)
ARR.Sfp|0|1|$$ELE
Speed in Ticks:
If you specify multiple Elements or Formulas, then its a bit slower.
Example
'***********************************
' ARR.-Sample for setting a floating-point array element
'***********************************
' Sets the 10th element of Floating-Point Array 5 to 3.14159
ARR.Set FP Array|5|10|3.14159
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