Program instructions
7.4 Compare
S7-200 SMART
196 System Manual, 09/2015, A5E03822230-AC
Compare character strings
The compare string instructions can compare two ASCII character strings.
For
and
When the comparison is TRUE, the compare instruction turns ON the
contact (LAD), or output (FBD).
For
: 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).
OS= IN1, IN2
AS= IN1, IN2
Compare two character strings of STRING data type:
The result is TRUE, if string IN1
string IN2.
OS<> IN1, IN2
AS<> IN1, IN2
Compare two character strings of STRING data type:
The result is TRUE, if string IN1
string IN2.