|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > Array -Commands > !FP-Arrays > Array - Commands |
MiniRobotLanguage (MRL)
ARR.ArrayToVarFp
Converts a global array of floating-point numbers into a single, CR-LF delimited variable.

Converts an array of floating-point values into a CR-LF delimited string stored in a variable.
Intention
The ARR.ArrayToVarFp command is a specialized version of ARR.ArrayToVar. It is designed to work with arrays populated with floating-point (EXTENDED) values using ARR.Set FP. It reads the binary numeric data from each array element, converts it to a readable string, and joins all the values into a single CR-LF delimited variable.
This command is useful for exporting floating-point array data to a format suitable for display, storage, or further processing. It requires two parameters: the array number and the destination variable. The array remains unchanged, and the result is stored in the specified variable.
•Data Conversion: Converts floating-point values to strings, preserving precision.
•Delimiter: Uses CR-LF to separate elements in the output variable.
•Array Integrity: The source array is not modified during the operation.
Schematic (Array to Variable Conversion)
Array[2]: ["3.14159", "2.71828", "-99.5"]
Command: ARR.ArrayToVarFp|2|$$RES
Result: $$RES = "3.14159\r\n2.71828\r\n-99.5"
Syntax
ARR.ArrayToVarFp|P1|P2
Parameter Explanation
•P1 - Array Number: The number (0–32) of the source global array containing floating-point data.
•P2 - Destination Variable: The variable where the final CR-LF delimited result string will be stored.
Speed in Ticks:
This command typically uses between 150 to 300 ticks, depending on the array size.
Examples
'***********************************
' Example 1: Displaying Float Array Contents
'***********************************
' First, create and populate an array with floats
ARR.Set FP|2|1|3.14159
ARR.Set FP|2|2|2.71828
ARR.Set FP|2|3|-99.5
' Now, convert that array into a single string variable
ARR.ArrayToVarFp|2|$$RES
' Display the results in a message box
MBX.Floating-point array contents:$$CRLF$$$$RES
ENR.
'***********************************
' Example 2: Converting Empty Array
'***********************************
ARR.Clr|3
ARR.ArrayToVarFp|3|$$RES
MBX.Empty array result:$$CRLF$$$$RES
ENR.
'============================================================
' SELF-VALIDATING TEST SCRIPT for ARR.ArrayToVarFp
' Purpose: Verify functionality with JIV. for automated checks.
' Tests converting arrays, empty arrays, and invalid parameters.
'============================================================
' Initialize counters
$$PAS=0
$$FAI=0
STS.CLEAR
PRT. ===================================================
PRT. Test 1.1: Convert a floating-point array
STS.CLEAR
ARR.Clr|1
ARR.Set FP|1|0|3.14,-2.718
ARR.ShowFP|1
ARR.ArrayToVarFp|1|$$RET
$$EXP=3.14$crlf$-2.718
JIV.$$RET!$$EXP|Lab_Error1
PRT. -> PASS
VIC.$$PAS
JMP.Lab_Next1
:Lab_Error1
GSB.Test
'-----------------------------------------------------------
:Lab_Next1
PRT. Test 1.2: Convert an empty array
STS.CLEAR
ARR.Clr|2
ARR.ArrayToVarFp|2|$$RET
$$EXP=
JIV.$$RET!$$EXP|Lab_Error2
PRT. -> PASS
VIC.$$PAS
JMP.Lab_Next2
:Lab_Error2
GSB.Test
'-----------------------------------------------------------
:Lab_Next2
PRT. Test 1.3: Invalid array number (negative)
STS.CLEAR
ARR.Clr|3
ARR.ArrayToVarFp|-1|$$RET
$$EXP=
JIV.$$RET!$$EXP|Lab_Error3
PRT. -> PASS
VIC.$$PAS
JMP.Lab_Next3
:Lab_Error3
GSB.Test
'-----------------------------------------------------------
:Lab_Next3
PRT. Test 1.4: Invalid parameter count (too few)
STS.CLEAR
ARR.Clr|4
ARR.ArrayToVarFp|4
$$EXP=
JIV.$$RET!$$EXP|Lab_Error4
PRT. -> PASS
VIC.$$PAS
JMP.Lab_Next4
:Lab_Error4
GSB.Test
:Lab_Next4
PRT. ===================================================
PRT. TEST SUMMARY
PRT. ===================================================
CAL.$$TOT=$$PAS+$$FAI
$$MSG=Total Tests: $$TOT
PRT.$$MSG
$$MSG=Passed: $$PAS
PRT.$$MSG
$$MSG=Failed: $$FAI
PRT.$$MSG
JIV.$$FAI=0|Lab_Success
$$MSG=FAILURE: $$FAI of $$TOT tests failed.
MBX.$$MSG|Test Result|16
JMP.Lab_End
:Lab_Success
MBX.SUCCESS: All tests passed!|Test Result|64
:Lab_End
ENR.
:Test
$$MSG= -> FAIL - Result: $$RET (exp: $$EXP)
PRT.$$MSG
VIC.$$FAI
RET.
Remarks
- This command has an alias: ARR.ATVF.
- Using this command on an array that contains string or integer data will produce incorrect or meaningless results.
- The command does not modify the source array.
- The output variable contains elements separated by CR-LF, suitable for further processing or display.
Limitations
- Array numbers are limited to 0–32, consistent with other MRL array commands.
- Invalid array numbers (e.g., negative or >32) result in no operation.
- The command requires exactly two parameters; fewer or more parameters result in no operation.
- No support for multidimensional arrays; use other commands for complex array structures.
See also: