Chapter 6 Applied Instructions Symbol S 1 : String to be searched S 2 : String to be searched for n : n th character in S 2 where the search begins D : Search result 6_ Explanation 1. This instruction searches the string in S 2 from the n th character for the string in S 1 , and stores the search result in D . 2. When the n th character exceeds the length of the string in S 2 , or S 1 > S 2 , D is 0. 3. Suppose the string in S 2 is “ABCDEFGHIJK”, the string in S 1 is “EFGH”, and n is 3. The search begins from the third character in S 2 , and the value in D is 5.
b15 b0 b 7 b8 S1 +1 S1 b15 b0 b 7 b8 S2 +2 S1 Matchin g chara ct er +1 S2 +2 S2 Se arch ing t he st ring f rom the th ird chara ct er +3 S2 +5 S2 +4 S2 Afte r the inst ruction is e xecuted 5 D 6-667 API Instruction code Operand Function 2115 $SER P S1, S2, n, D Searching a string Device X Y M S T C HC D FR SM SR E K 16# “$” F S1 S2 n D BOOL WORD DWORD LWORD UINT INT DINT LINT REAL LREAL TMR CNT STRING Data type S1 S2 n D Pulse instruction 16-bit instruction 32-bit instruction ES3 ES3 - 1 6#46 (F) 1 6#45(E) 1 6#4 8(H) 1 6#47 (G) 忽Ig 略n o r e d 16 #00 16#4 2(B) 16#4 1(A) 16#4 4(D) 16#4 3(C) 16 #46(F) 16# 45(E) 16 #48(H) 16#47(G) 16#4A(J) 1 6#4 9(I ) 16 #00 16#4B(K)