Program instructions
7.4 Compare
S7-200 SMART
234
System Manual, V2.3, 07/2017, A5E03822230-AF
7.4.2
Compare character strings
The compare string instructions can compare two ASCII character strings.
For LAD and FBD: When the comparison is TRUE, the compare instruction turns ON the
contact (LAD), or output (FBD).
For STL: When the comparison is TRUE, the compare instruction loads, ANDs, or ORs a 1
with the value on the top of the logic stack.
Comparisons can be made between two variables, or between a constant and a variable. If a
constant is used in a comparison, then it must be the top parameter (LAD contact / FBD box)
or the first parameter (STL).
In the program editor, a constant string parameter assignment must begin and end with a
double quote character. The maximum length of a constant string entry is 126 characters
(bytes).
In contrast, a variable string is referenced by the byte address of the initial length byte with
the character bytes stored the next byte addresses. A variable string has a maximum length
of 254 characters (bytes) and can be initialized in the data block editor (with beginning and
ending double quote character).
LAD contact
FBD box
STL
Description
LDS= IN1, IN2
OS= IN1, IN2
AS= IN1, IN2
Compare two character strings of STRING data type:
The result is TRUE, if string IN1 equals string IN2.
LDS<> IN1, IN2
OS<> IN1, IN2
AS<> IN1, IN2
Compare two character strings of STRING data type:
The result is TRUE, if string IN1 does not equal string IN2.