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

4
14
PM Designer Operation Manual
14-43
CHAPTER 14 USING MACROS
I2A
Format
P1
= I2A(P2,P3 )
Data Type
U/S/UD/SD
Function
Converts the integer 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 integer number or the location that holds the integer number to be converted.
P3 (I/C)
Specifies the maximum number of digits the string can have.
P4 (I/C)
Specifies where to insert a decimal point in the string. A decimal point is inserted to the left of the
nth digit when P4 is n. No decimal point is inserted when P4 is 0.
Example 1
$U120
=
123
$U100
= I2A(
$U120
,
5, 0
)
/* After this command is executed, the byte array $U100 contains
“123”. */
Example 2
$U120
=
1234567
(UD)
$U100
= I2A(
$U120
, 6, 2) (UD)
/* After this command is executed, the byte array $U100 contains
“2345.67”. */
Example 3
$U120
= -
12345
(S)
$U100
= I2A(
$U120
,
5, 1
) (UD)
/* After this command is executed, the byte array $U100 contains
“-1234.5”. */
A2I
Format
P1
= A2I(P2,P3,P4 )
Data Type
U/S/UD/SD
Function
Converts the string P2 to an integer value 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.
P4 (I/C)
Specifies how many fractional digits in the string are to be converted.
Example 1
$U120
= “
123”
$U100
= A2I(
$U120
,
0, 0
)
/* After this command is executed, the value in word $U100 is 123. */
Example 2
$U120
= “
1234567”
$U100
= A2I(
$U120
,
6
,
0
) (UD)
/* After this command is executed, the value in double word
$U100 is 123456. */
Example 3
$U120
= “-
123.45”
$U100
= A2I(
$U120
,
0, 2
) (S)
/* After this command is executed, the value in word $U100 is
-12345. */