Pm designer operation manual – B&B Electronics WOP-2121V-N4AE - Manual User Manual
Page 453

14
PM Designer Operation Manual
14-44
CHAPTER 14 USING MACROS
F2A
Format
P1
= F2A(P2,P3 )
Data Type
F
Function
Converts the floating point number in P2 to a string and saves the result in P1. The string is
generated according to the format specified by P3 and P4.
P1 (I)
The byte array that stores the result. The result is a null terminated string.
P2 (I/C)
The floating point number or the location that holds the floating point number to be converted.
P3 (I/C)
Specifies the number of integral digits the string can have.
P4 (I/C)
Specifies the number of fractional digits the string can have.
Example 1
$U120
=
123.45 (F)
$U100
= F2A(
$U120
,
5, 2
)
/* After this command is executed, the byte array $U100 contains
“123.45”. */
Example 2
$U120
=
1234
(F)
$U100
= F2A(
$U120
, 6, 2) (UD)
/* After this command is executed, the byte array $U100 contains
“1234.00”. */
Example 3
$U120
= -
1234.5
(S)
$U100
= F2A(
$U120
,
5, 1
) (UD)
/* After this command is executed, the byte array $U100 contains
“-1234.5”. */
A2F
Format
P1
= A2F(P2,P3 )
Data Type
F
Function
Converts the string P2 to a floating point number and saves the result in P1.
P1 (I)
The location that stores the result. The result is 0 when there is any conversion error.
P2 (I)
The byte array that holds the string to be converted.
P3 (I/C)
Specifies the length of the string. It is allowed to specify 0 for P3. When P3 is 0, the string must be
a null terminated string.
Example 1
$U120
= “
123.4”
$U100
= A2F(
$U120
,
0
)
/*The value of the floating point number in double word $U100 is 123.4. */
Example 2
$U120
= “
1234567”
$U100
= A2F(
$U120
,
6
) (UD)
/* The value of the floating point number in double word $U100 is
123456. */
Example 3
$U120
= “-
123.45”
$U100
= A2F(
$U120
,
0
) (S)
/* The value of the floating point number in double word $U100 is
-123.45. */