627
FX3G/FX3U/FX3UC Series Programmable Controllers
Programming Manual - Basic & Applied Instruction Edition
26 Character String Control – FNC200 to FNC209
26.5 FNC204 – RIGHT / Extracting Character String Data from the Right
21
FNC160-FNC169
Real Time Clock
Control
22
FNC170-FNC179
External Device
23
FNC180
Alternate
Instructions
24
FNC181-FNC189
Others
25
FNC190-FNC199
Block Data
Operation
26
FNC200-FNC209
Character String
Control
27
FNC210-FNC219
Data
Operation 3
28
FNC220-FNC249
Data
Comparison
29
FNC250-FNC269
Data Table
Operation
30
FNC270-FNC274
Ex-Device
Inverter Comms
• A character string stored in and later indicates data stored in devices from the specified device until "00H" is
first detected in byte units.
Cautions
When handling character codes other than ASCII codes, note the following contents:
• The number of characters is handled in byte units (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”.
• When extracting characters from a character string including character codes in which 2 bytes express 1 character
such as shift JIS codes, consider the number of characters to be extracted in units of character codes for 1
character.
Note that the expected character code is not given if only 1 byte is executed out of a 2-byte character code.
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 “n” exceeds the number of characters specified by (error code: K6706)
• When the number of devices after a device number specified by is smaller than the number of devices
required to store extracted “n” characters (that is, when “00H” cannot be stored after all character strings and the
last character) (error code: K6706)
• When “n” is a negative value (error code: K6706)
Program example
In the program example shown below, 4 characters are extracted from the right end of the character string data stored
in R0 and later, and stored to D0 and later when X000 turns ON.
34H(4)
32H(2) 31H(1)
33H(3)
35H(5)
31H(1)32H(2)
34H(4) 33H(3)
35H(5)
ASCII code for 5th character
+1
+2
S
S
S
+4S
+3S
+5S
In the case of “n = 5”
b15----------------------b8b7-----------------------b0
42H(B) 41H(A)
44H(D) 43H(C)
46H(F) 45H(E)
00H
“ABCDEF12345”
D
D
+1
+2
00H
“12345”
b15----------------------b8b7-----------------------b0
D
ASCII code for 1st character
S
S
S
D
41H(A)
45H(E) 30H(0)
46H(F)
45H(E) 30H(0)
41H(A) 46H(F)
X000
D0
FNC204
RIGHTP
R0
END
K4
ASCII code for 4th character
R1
R2
R4
R3
b15----------------------b8b7-----------------------b0
41H(A) 42H(B)
31H(1) 32H(2)
“BA210EFA”
D1
D2
0000H
“0EFA”
b15----------------------b8b7-----------------------b0
R0 D0
ASCII code for 1st character
00H