Program instructions
7.15 String
S7-200 SMART
System Manual, V2.3, 07/2017, A5E03822230-AF
365
7.15.3
Find string and first character within string
LAD / FBD
STL
Description
SFND IN1, IN2, OUT
STR_FIND searches for the first occurrence of the string IN2 within the
string IN1. The search begins at the starting position assigned by the initial
value of OUT (which must be in the range of 1 to the IN1 string length be-
fore STR_FIND execution). If a sequence of characters is found that match-
es exactly the string IN2, the position of the first character in the sequence
within the IN1 string is written to OUT. If the string IN2 was not found in the
string IN1, then OUT is set to 0.
CFND IN1, IN2, OUT
CHR_FIND searches the string IN1 for the first occurrence of any character
from the character set in the string IN2. The search begins at starting posi-
tion assigned by the initial value of OUT (which must be in the range of 1 to
the IN1 string length before CHR_FIND execution). If a matching character
is found, then the position of the character is written to OUT. If no matching
character is found, OUT is set to 0.
Note: Because Chinese characters are not represented by a single byte, and the string instructions operate on bytes and
not characters, unexpected results can occur with the STR_FIND and CHR_FIND instructions with strings containing
Chinese characters.
Non-fatal errors with ENO = 0
SM bits affected
•
0006H Indirect address
•
0091H Operand out of range
•
009BH Index = 0
None
Input / output
Data type
Operand
IN1, IN2
STRING
VB, LB, *VD, *LD, *AC, Constant String
OUT
BYTE
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC