11 - 108 11 - 108
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
KINSTR
Function
Kanji INSTRing
• Searches through a character string containing full-byte characters for the specified
character string and displays the first location in which it is found.
KINSTR ([ <arithmetic expression > ,] <character string expression 1>, < character string
expression 2> )
arithmetic expression
• • • •
Specify the location to start searching the character
string.
character string expression 1
• • • •
Specify the target character string.
Syntax
character string expression 2
• • • •
Specify the character string to be searched.
J=KINSTR(3, A$, “NAGOYA”)
• • • •
Searches the character string “NAGOYA” from the
third character of A$, and assigns the location if
found or assigns 0 if not found to J.
Examples
A$
A$
@460@@@@@@@@@5- 14
@100@
@
@@@@
@@@@2 2- 3
-
1 2 3 4 5 6 7 8
Search range
J
5
J
0
• The KINSTR function searches <character string expression 2> in <character string
expression 1>, then returns the location of the first match if found or returns 0 if not found.
• The KINSTR function processes full-byte characters (Kanji) as one character.
• <Numeric expression> specifies the search starting position. If omitted, the search will be
performed from the beginning of <character string expression 1>. If the value is greater
than <character expression 1>, the KINSTR function will return "0."
Description
• If <character string expression 2> is an empty character string, the KINSTR function will
return the same value as <numeric expression>.