11 - 96 11 - 96
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
INSTR Function
IN STRing
• Searches a specified character string in the character string and returns the position of the
first match.
INSTR ([ <numeric expression > ,] <character string expression 1>, < character string
expression 2> )
numeric expression
• • • •
Specify the position 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.
A=INSTR(2, A$, “ABC”)
• • • •
Searches the character string “ABC” from the second
character of A$, and assigns the position if found or
assigns 0 if not found to A.
Examples
A$
1 2 3 4 A B C D E
1 2 3 4 5 6 7 8 9 10
A$
A B 1 2 3 4 C D E F
A
A
5
0
F
Search area
Description
• The INSTR function searches <character string expression 2> in <character string
expression 1>, then returns the position of the first match if found or returns 0 if not found.
• Specify the position to start the search to <numeric expression>. If omitted, the search
starts from the beginning of <character string expression 1>, and the INSTR function
returns 0 if a value larger than the number of characters in <character string expression 1>
is specified.
• 0 is returns if <character string expression 1> is an empty character string.
• The same value as <numeric expression> is returned if <character string expression 2> is
an empty character string.
• The INSTR function processes a full-byte character as two half-byte characters. See the
KINSTR function for searching a full-byte character as one character.
A$
A B
@
@
C D
A$
8
6
INSTR(A$, "D" )
KINSTR(A$, "D" )
1 2 3 4 5 6 7 8
1 2
3
4
5 6
A B
@
@
C D
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...