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

4
14
PM Designer Operation Manual
14-41
CHAPTER 14 USING MACROS
STRLEN
Format
P1
= STRLEN(P2 )
Function
Gets the length of string P2 and saves the result in P1.
P1 (I)
The word to receive the result.
P2 (I)
The byte array that stores the null-terminated string.
Example 1
$U10
=
“ABC”
$U20
= STRLEN(
$U10
)
/* After this command is executed, the value of $U20 is 3. */
NUM2STR
Format
P1
= NUM2STR(P2,P3 )
Data Type
U/UD
Function
Converts the number in P2 to a string with P3 characters and saves the result in P1.
P1 (I)
The byte array that stores the result.
P2 (I/C)
The number or the location that holds the number to be converted.
P3 (I/C)
Specifies the exact number of characters that the result should have. If the number of digits of P2
is less than P3, the result is padded on the left with zeros. If the number of digits of P2
exceeds
P3, the higher digits are truncated. If P3 is 0, there is no limitation on the length of the result.
Example 1
$U120
=
123
$U100
= NUM2STR(
$U120
,
0
) (U)
/* After this command is executed, the byte array $U100
contains “123”. */
Example 2
$U120
=
1234567
(UD)
$U100
= NUM2STR(
$U120
,
10
) (UD)
/* After this command is executed, the byte array $U100
contains “0001234567”. */
Example 3
$U120
=
1234567
(UD)
$U100
= NUM2STR(
$U120
,
5
) (UD)
/* After this command is executed, the byte array $U100
contains “34567”. */
TIME2STR
Format
P1
= TIME2STR(P2 )
Data Type
U
Function
Converts the current system time to a string using the format specified by P2 and saves the result
in P1.
P1 (I)
The byte array that stores the result.
P2 (I/C)
Specifies the desired conversion format.
Format
P2
Value
Remark
hhmmss
0
hh: hour(00~23); mm: minute(00~59); ss: second(00~59)
hhmm
1
hh, mm: same as above
Example 1
$U10
= TIME2STR(
0
)
/* Assume that the current system time is 12:30:59. After this command is
executed, the byte array $U10 contains “123059”. */