22 CHARACTER STRING FUNCTIONS
22.2 Extracting Character String Data from the Left/Right
815
22
22.2 Extracting Character String Data from the Left/
Right
LEFT(_E), RIGHT(_E)
• LEFT(_E): These functions output specified number of characters from the left of input character string data.
• RIGHT(_E): These functions output specified number of characters from the right of input character string data.
â– Descriptions, types, and data types
â– Operation processing
•LEFT(_E)
When the value input to (n) is 7
Ladder diagram Structured text
[Without EN/ENO] [With EN/ENO] [Without EN/ENO]
d:=LEFT(s,n);
d:=RIGHT(s,n);
[With EN/ENO]
d:=LEFT_E(EN,ENO,s,n);
d:=RIGHT_E(EN,ENO,s,n);
Argument Description Type Data type
EN Execution condition (TRUE: Execution, FALSE: Stop) Input variable BOOL
s Input Input variable STRING(255)
n Specification of number of characters to be extracted Input variable INT
ENO Output status (TRUE: Normal, FALSE: Abnormal) Output variable BOOL
d Output Output variable STRING(255)
These functions output the data for the specified number of characters from the left of a character string input to (s) from (d).
The value input to (n) specifies the number of characters to be extracted.
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
4th word
3rd word
1st word
42H (B) 41H (A)
44H (D) 43H (C)
00H
46H (F)
31H (1)
45H (E)
High-order byte Low-order byte High-order byte Low-order byte
"ABCDEF12345" "ABCDEF1"
Number of
characters to be
extracted (L): 7