612
FX
3U
/FX
3UC
Series Programmable Controllers
Programming Manual - Basic & Applied Instruction Edition
26 Character String Control – FNC200 to FNC209
26.4 FNC203 – LEN / Character String Length Detection
Caution
• This instruction can handle character codes other than ASCII codes, but the character string length is
handled in units of byte (8 bits). Accordingly, in the case of character codes in which 2 bytes express 1
character such as shift JIS codes, the length of 1 character is detected as “2”.
Errors
An operation error is caused in the following cases; The error flag M8067 turns ON, and the error code is
stored in D8067.
• When “00H” is not set within the corresponding device range after a device specified by
(error code:
K6706)
• When the detected number of characters is “32768” or more (error code: K6706)
Program example
In the program example shown below, the length of a character string stored in D0 and later is output in 4-digit
BCD to Y040 to Y057 when X000 turns ON.
S
X000
D10
FNC203
LEN
D0
END
K4Y40
FNC 18
BCD
D10
The length of the character
string is output to the display
unit.
b15---b8
D0
D1
49H(I) 4DH(M)
53H(S) 54H(T)
53H(S)
D10
10
D3
42H(B) 55H(U)
49H(I)
“MITSUBISHI”
(Characters
after “00H” are
ignored.)
49H(I)
48H(H)
D2
D4
D6
D5
43H(C)
41H(A)
00H
42H(B)
Conversion
into BCD
BCD
0 0
0
1
BCD value
Y057 to Y040
“ ABC.......”
b7----b0