22 CHARACTER STRING FUNCTIONS
22.3 Extract Mid String
817
22
22.3 Extract Mid String
MID(_E)
These functions output the specified number of characters from an arbitrary position of an input character string.
â– Descriptions, types, and data types
â– Operation processing
• These functions output the data for the specified number of characters from an arbitrary position of a character string input
to (s).
• The value input to (n1) specifies the number of characters to be extracted.
• The value input to (n2) specifies the number of the head character position of a character string to be extracted.
When the value input to (n1) and (n2) is 5
• A value input to (s) is the STRING type data value and within the range from 0 to 255 byte(s).
• A value input to (n1) is the INT type data value and within the range from 0 to 255. (However, the value must be within the
number of characters of the character string to be input to (s).)
• A value input to (n2) is the INT type data value and within the range from 1 to 255. (However, the value must be within the
number of characters of the character string to be input to (s).)
Ladder diagram 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: Execution, FALSE: Stop) Input variable BOOL
s Input Input variable STRING(255)
n1 Specification of number of characters to be extracted Input variable INT
n2 Specification of head character position of a character string to be
extracted
Input variable INT
ENO Output status (TRUE: Normal, FALSE: Abnormal) Output variable BOOL
d Output Output variable STRING(255)
42H (B) 41H (A)
44H (D) 43H (C)
46H (F) 45H (E)
32H (2) 31H (1)
34H (4) 33H (3)
00H 35H (5)
2nd word
3rd word
4th word
5th word
6th word
1st word
2nd word
3rd word
1st word
46H (F) 45H (E)
32H (2) 31H (1)
00H 33H (3)
High-order byte Low-order byte High-order byte Low-order byte
"ABCDEF12345" "EF123"
(s)
(d)
Head character
position of a
character string to
be extracted
n2
:
5th character
Number of characters
to be extracted
n1
: 5