Mitsubishi Electronics FXCPU Video Game Controller User Manual


 
26 Applied Instructions (Character String Control)
26.5 RIGHT / Extracting Character String Data from the Right
636
FXCPU Structured Programming Manual
[Basic & Applied Instruction]
Cautions
1) When handling character codes other than ASCII codes, note the following contents:
a) The number of characters is handled in byte units (8 bits). Accordingly, in the case of character codes
in which two bytes express one character such as shift JIS codes, the length of one character is
detected as "2".
b) When extracting characters from a character string including character codes in which two bytes
express one character such as shift JIS codes, consider the number of characters to be extracted in
units of character codes for one character.
Note that the expected character code is not given if only one byte is extracted out of a 2-byte
character code.
Error
An operation error is caused in the following cases. The error flag M8067 turns ON, and the error code is
stored in D8067.
1) When "00H" is not set within the corresponding device range after a device specified by .
(Error code: K6706)
2) When "n" exceeds the number of characters specified by . (Error code: K6706)
3) 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)
4) When "n" is a negative value. (Error code: K6706)
Program examples
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.
[Structured ladder/FBD] [ST]
RIGHTP(X000,R0,K4,D0);
X000
RIGHTP
EN ENO
d
s
n
R0
D0
K4
41H(A)
45H(E) 30H(0)
46H(F)
45H(E) 30H(0)
41H(A) 46H(F)
ASCII code for 4th character
R1
R2
R4
R3
41H(A) 42H(B)
31H(1) 32H(2)
00H
"BA210EFA"
D1
D2
0000H
"0EFA"
R0 D0
ASCII code for 1st character
b15 b8 b7 b0 b15 8b 7b b0