32 STRING FUNCTIONS
32.3 Extracting String Data
1949
32
32.3 Extracting String Data
MID(_E)
These functions extract and output the specified number of characters, starting from the specified position of the string input.
■Description, type, data type
■Operation processing
• These functions extract the specified number of characters, starting from the specified position of the string input to (s), and
output the operation result from (d).
• Specify the number of characters to be extracted in (n1).
• Specify the start position of the string to be extracted in (n2).
When (n1)=5, (n2)=5
• Input a STRING data type value to (s) within the range of 0 to 255 bytes.
• Input an INT data type value to (n1) within the range of 0 to 255, provided that it is within the number of characters in the
string input to (s).
• Input an INT data type value to (n2) within the range of 1 to 255, provided that it is within the number of characters in the
string input to (s).
Ladder, FBD/LD Structured text
[Without EN/ENO] [With EN/ENO] [Without EN/ENO]
d:=MID(s,n1,n2);
[With EN/ENO]
d:=MID_E(EN,ENO,s,n1,n2);
Argument Description Type Data type
EN Execution condition (TRUE: Executed, FALSE: Not executed) Input variable BOOL
s (IN) Input Input variable ANYSTRING_SINGLE
n1 (L) Number of characters to be extracted Input variable INT
n2 (P) Extraction target character start position Input variable INT
ENO Output status (TRUE: Normal, FALSE: Abnormal) Output variable BOOL
d Output Output variable ANYSTRING_SINGLE
RnCPU
RnENCPU
RnSFCPU RnSFCPURnPCPURnPCPU
(Standard) (Safety)
(Redundant)
(Process)
EN ENO
ds
n1
n2
(s)
(d)
EF123ABCDEF12345
33H(3)00H
31H(1)32H(2)
45H(E)46H(F)
35H(5)00H
33H(3)34H(4)
31H(1)32H(2)
45H(E)46H(F)
43H(C)44H(D)
41H(A)42H(B) +0
+2
+1
+0
+5
+4
+3
+2
+1
Lower byteUpper byteLower byteUpper byte
Starting position specified
by (n2): 5th character
Number of characters
to be extracted (n1): 5