3 - 40 3 - 40
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
3.13 Character Processing
3.13.1 Types of characters
There are three basic categories of characters used in BASIC.
• Half-byte characters
(1-byte characters)
• • • • • These are characters that can be input from the
keyboard and include numbers, alphabet characters,
English symbols, Katakana, etc.
• Full-byte characters
(2-byte characters)
• • • • • These include Kanji and Hiragana characters. Full-byte
characters are displayed on the screen using the
space equal to 2 half-byte characters on the screen.
They also requires the amount of space for 2 half-byte
characters when saving to a memory card, FD, etc.
• Control characters
• • • • • Control characters refer to character codes 00h
through 1Fh. These are not normally used, and
produce the same result as when pressing the
key, key, key, key, or Ctrl +
keys on the keyboard. To specify these characters, the
CHR$ function is used.
3.13.2 Half-byte character unit processing
(1) To extract a portion of a character string
There are three functions that can be used to extract a certain portion of a
character string and create a new character string. The following shows an
example:
• The instruction may not
be executed properly if
this is used on a character
string containing full-byte
characters
(Kanji characters).
For details, see (5).
• MID$ has a function to
change a certain portion
of the character string.
For details, see the
description of MID$.
Example
10 A$ = " ABCDEFGHIJ"
20 B$=LEFT$ (A$, 4)
30 PRINT B $
RUN
ABCD
OK
LEFT$(A$, n) creates a new character string by extracting up to the nth
character counting from the left within the character string A$.
Example
10 A$ = " ABCDEFGHIJ"
20 B$=RIGHT $(A$, 4)
30 PRINT B $
RUN
GHIJ
OK
RIGHT$(A$, n) creates a new character string by extracting up to the nth
character counting from the right within the character string A$.
Example
10 A$ = " ABCDEFGHIJ"
20 B$=MID $(A$, 4, 3)
30 PRINT B $
RUN
DEF
OK
MID$(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$.