Program instructions
7.4 Compare
S7-200 SMART
System Manual, 09/2015, A5E03822230-AC
197
Note
The following conditions cause a non-fatal error, set power flow to OFF (ENO bit = 0), and
use value 0 as the result of the comparison:
Illegal indirect address is encountered (any compare instruction)
A variable string with a length greater than 254 characters is encountered (Compare
String instruction)
A variable string whose starting address and length are such that it will not fit in the
specified memory area (Compare String instruction)
To prevent these conditions from occurring, ensure that you properly initialize pointers and
memory locations that are intended to hold ASCII s
trings prior to executing compare
instructions that use these values. Ensure that the buffer reserved for an ASCII string can
reside completely within the specified memory area.
Compare instructions are executed regardless of the state of power flow.
VB, LB, *VD, *LD, *AC, Constant string
OUT BOOL LAD: Power flow
FBD: I, Q, V, M, SM, S, T, C, L, Logic Flow
Format of the STRING data type
A string variable is a sequence of characters, with each character stored as a byte. The first
byte of the STRING data type defines the length of the string, which is the number of
character bytes.
The diagram below shows the STRING data type stored as a variable in memory. The string
can have a length of 0 to 254 characters. The maximum storage requirement for a variable
string is 255 bytes (the length byte plus 254 characters).
If a constant string parameter is entered directly in the program editor (126 characters
maximum) or a variable string is initialized in the data block editor (254 characters
maximum), the string assignment must begin and end with double quote characters.
Constants (Page 69)