11 - 118 11 - 118
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
KTYPE
Function
Kanji TYPE
• Returns the character type of the specified position within the character string that includes
full-byte characters.
KTYPE ( <character string expression> , <numeric expression> )
character string expression
• • • •
Specify the applicable character string for the
process
Syntax
numeric expression
Specify the character position within the character
string in which the type is verified.
Examples
A=KTYPE(A$,4)
• • • •
Counts the characters from the left of A$ and
assigns the character type of the fourth character to
A.
AB @ @ @ @
A$
1
A
1 2 3
4
Full-byte character
• The KTYPE function returns the character type of the character corresponding to the
number of characters specified by <numeric expression> in <character string expression>
counting from the left as follows. Full-byte characters are counted as one character.
0
• • • •
Half-byte characters (numbers, alphabets, Kana characters, etc.)
1
• • • •
Full-byte characters (Kanji, etc.)
Description
• If the value of <numeric expression> is 0 or greater than the number of characters in the
character string, an “Illegal function call” error will be generated. This error will also be
generated when the <character string expression> is “ “ (empty character expression).
Program Example
10 ' Checks the character type
20 A$="@@@@@@@"
:
' Defines the character string
30 A=KTYPE(A$,6)
: ' Character type of the 6th character from
the left
50 PRINT "Character type is";A
60 END
RUN
Character type is 1
OK
REMARK
See the KINSTR, KLEN and KMID$ functions.