Extended instructions
9.2 String and character
S7-1200 Programmable controller
364 System Manual, V4.2, 09/2016, A5E02486680-AK
LEFT, RIGHT, and MID (Read substrings in a character string) instructions
Table 9- 55 Left, right and middle substring operations
LEFT (Left substring) provides a substring made of the first L charac-
ters 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.
MID (Middle substring) provides the middle part of a string. The middle
substring is L characters long and starts at character position P (inclu-
sive)
If the sum of L and P exceeds the current length of the string parame-
ter IN, then a substring is returned that starts at character position P
and continues to the end of the IN string.
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 9- 56 Data types for the parameters
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