Delta AH500 — 6.21.2 Explanation of String Processing Instructions

AH500 Programming Manual API 2106 Symbol: S : String Word/Double word D : Length of the string Word/Double word Explanation: 1. The length of the string in S is calculated, exclusive of 16#00 with which the string ends. The length of the string is stored in D . 2. The value stored in D should be within the range between 0 and 65535. If the number of characters contained in the string is 65536, which is equal to 16#10000, the value in D is 0. If the number of characters contained in the string is 65537, which is equal to 16#10001, the value in D is 0. b15 b0 b7 b8 S S+1 b15 b0 D S+2 n Length of the string If the data in S ~ S +4 is ABCDEFGHI, the calculation result is as follows.

S+n b15 b0 b7 b8 S S+1 b15 b0 D S+2 ABCDEFGHI 9 S+3 S+4 Example 1: Suppose S is the string “DELTA”. When the PLC runs, the value in D0 is 5. 6-458 Instruction code Operand Function $LEN P S, D Calculating the length of the string Device X Y M S T C HC D L SM SR E PR K 16# “$” DF S          D          Pulse instruction 16-bit instruction (5-11 steps) 32-bit instruction AH500 AH500 - Second character First character Fourth character Third character Sixth character Fifth character 16#00 (Endind character) n th character 16#42(B) 16#41(A) 16#44(D) 16#43(C) 16#46(F) 16#45(E) 16#48(H) 16#47(G) 16#00 (Ending character) 16#49(I)