Mitsubishi Electronics FXCPU Video Game Controller User Manual


 
26 Applied Instructions (Character String Control)
26.7 MIDR / Random Selection of Character Strings
642
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 the value specified by exceeds the number of characters specified by .
(Error code: K6706)
3) When the number of characters specified by " +1" from the position specified by the device specified
by exceeds the device range specified by . (Error code: K6706)
4) When the number of devices after a device number specified by is smaller than the number of
devices required to store extracted characters as many as the number specified by " +1" (that is,
when "00H" cannot be stored after all character strings and the last character) (Error code: K6706)
5) When the contents of the device specified by is a negative value. (Error code: K6706)
6) When the contents of the device specified by " + 1" is "-2" or less. (Error code: K6706)
7) When the contents of the device specified by " + 1" is a number larger than the number of characters
specified by .
(Error code: K6706)
Program examples
In the program example shown below, four characters are extracted from the third character from the left end
of the character string data stored in D10 and later, and then stored to D0 and later when X000 turns ON.
X000
MIDR
EN ENO
d
s1
s2
D0
D10
R0
[Structured ladder/FBD] [ST]
MIDR(X000,D10,R0,D0);
31H(1) 32H(2)
46H(E) 33H(3)31H(1) 32H(2)
46H(E) 33H(3)
D11
D12
D13
41H(A) 42H(B)
00H
45H(D)
"BA213ED"
D1
D2
0000H
"213E"
D10 D0
R1
4
3
R0
3rd character
Four characters
from 3rd character
Extracted characters
b15 b8 b7 b0 b15 b8 b7 b0