3 - 44 3 - 44
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
3.13.3 Processes in full-Byte character increments
As shown in (5) in Section 3.13.2, a single full-byte character (Kanji character) is
considered as taking up the space equivalent to two single-byte characters in the
character processing in half-byte character increments. However, in the processing of
full-byte character increments, full-byte characters are also considered one character
when processed.
(1) Extracting a portion of a character string
The KMID$ function is similar to the MID$ function ((1) in Section 3.13.1)
explained in the processing of half-byte character increments. KMID$(A$, n, m)
creates a new character string by extracting m characters from the nth character
counting from the left within the character string A$. When this is performed, full-
byte characters are considered one character, and the result is as follows.
Example
10 A$= " A B C
20 PRINT MID$(A$, 8, 4)
30 PRINT KMID$(A$, 6, 2)
40 END
RUN
@@
MID$
KMID$
A
B
C
@
@
@
@
D
E
F
2
1
3
5
4
6 7 8 9
11
10
12
13
14
1
2
3
4
5
6
7
8
9
10
D E F"
@ @ @ @
OK
@@
(2) Finding the length of a character string
The KLEN function is used to find the length of a character string containing full-
byte characters. The KLEN function has many functions, and each function is
specified by integers 0, 1, or 2.
Example
10 A$= " A B C
20 PRINT KLEN(A$,0)
30 PRINT KLEN(A$,1)
40 PRINT KLEN(A$,2)
RUN
10
6
4
OK
Displays the number of half-byte
characters in A$.
Displays the number of full-byte characters in A$.
Displays the number of characters
in the entire
A$ character string. Full-byte characters are
counted as one character when this is processed.
D E F"
@ @ @ @