627
FX
3U
/FX
3UC
Series Programmable Controllers
Programming Manual - Basic & Applied Instruction Edition
26 Character String Control – FNC200 to FNC209
26.9 FNC208 – INSTR / Character string search
21
FN
C
160-FN
C
169
R
eal
Ti
m
e
C
loc
k
C
ont
ro
l
22
FN
C
170
-F
N
C
17
9
E
xt
e
rnal
D
evi
ce
23
FN
C
180
Su
b
st.
I
n
str
. I
n
fo
24
FN
C
181-FN
C
189
O
ther
s
25
FN
C
190-FN
C
19
9
B
loc
k D
a
ta
O
per
at
io
n
26
FN
C
200-FN
C
209
C
har
act
e
r St
ring
C
ont
ro
l
27
F
N
C2
10
-F
NC
21
9
Da
ta
O
per
at
ion 3
28
FN
C
220-FN
C
24
9
Da
ta
Co
m
p
a
ris
o
n
29
FN
C
250-FN
C
269
Da
ta
T
a
b
le
O
per
at
io
n
30
FN
C
27
0-F
N
C
274
Ex
-D
ev
ic
e
In
ve
rte
r C
o
mm
s
4) A character string can be directly specified in the character string
.
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 the search start position "n" exceeds the number of characters stored in
(error code: K6706)
• When "00H (NULL)" is not located within the corresponding device range starting from
(error code: K6706)
• When "00H (NULL)" is not located within the corresponding device range starting from
(error code: K6706)
Program example
1) In the program example below, the character string "C123" (D0 and later) is searched from the 5th
character from the left end (head character) of the character string "C123121CM" (R0 and later) when
X000 is set to ON. The search result is stored in D100
S
1
42H(B)
41H(A)
+0
b15
+2
+3
+4
b8 b7
b0
"1234AB56AB"
S
2
+1
+5
32H(2)
34H(4)
36H(6)
31H(1)
33H(3)
35H(5)
42H(B)
41H(A)
00H
"AB"
5
D100
Search is started from
the 3rd character (n = 3).
Fifth character from
the head character
Character string
Character string to be searched
S
1
S
2
S
2
S
1
S
2
X000
FNC208
INSTR
D0
R0
D100
K5
R0
b15
R2
R3
R4
b8 b7
b0
"C12312CIM"
R1
These characters are not
searched because the
search start position is "5".
The search source
character string is searched
from the 5th character.
32H(2)
49H(I)
31H(1)
43H(C)
49H(I)
33H(3)
43H(C)
32H(2)
00H
4DH(M)
D0
b15
b8 b7
b0
"C123"
D1
D2
0
Because the searched
character string is not
detected, "0" is stored.
49H(I)
33H(3)
43H(C)
32H(2)
00H
D100
END
Character string to be searched R0
Character string D0