101BExtended instructions
8.2 String and character
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
255
ENO
Condition
OUT
Maximum length of IN1 or IN2 is 255, or the maximum length of OUT is 0
or 255
8.2.4.3
LEFT, RIGHT, and MID
Table 8- 56 Left, right and middle substring operations
LAD / FBD
SCL
Description
out := LEFT(in, L);
LEFT (Left substring) provides a substring made of the first L
characters of string parameter IN.
If L is greater than the current length of the IN string, then the entire
IN string is returned in OUT.
If an empty string is the input, then an empty string is returned in
OUT.
out := MID(in, L, p);
MID (Middle substring) provides the middle part of a string. The middle
substring is L characters long and starts at character position P
(inclusive).
If the sum of L and P exceeds the current length of the string
parameter IN, then a substring is returned that starts at character
position P and continues to the end of the IN string.
out := RIGHT(in, L);
RIGHT (Right substring) provides the last L characters of a string.
If L is greater than the current length of the IN string, then the entire
IN string is returned in parameter OUT.
If an empty string is the input, then an empty string is returned in
OUT.
Table 8- 57 Data types for the parameters
Parameter and type
Data type
Description
IN
IN
String
Input string
L
IN
Int
Length of the substring to be created:
LEFT uses the left-most characters number of characters in the
string
RIGHT uses the right-most number of characters in the string
MID uses the number of characters starting at position P within
the string
P
IN
Int
MID only: Position of first substring character to be copied
P= 1, for the initial character position of the IN string
OUT
OUT
String
Output string