Extended instructions
9.2 String and character
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
361
Table 9- 46 ATH and HTA condition codes
0007 Invalid ATH input character: A character was found that was not an ASCII character 0-
9, lowercase a to f, or uppercase A to F
FALSE
Illegal or invalid input pointer, for example, an access to a DB that does not exist.
8120 Input string is an invalid format, i.e., max= 0, max=255, current>max, or grant length in
FALSE
Input buffer is too small for N
Data type not allowed for input buffer
Illegal or invalid output pointer, for example, an access to a DB that does not exist.
8320 Output string is an invalid format, i.e., max= 0, max=255, current>max, or grant length
FALSE
Output buffer is too small for N
Data type not allowed for output buffer
String operation instructions
Your control program can use the following string and character instructions to create
messages for operator display and process logs.
MAX_LEN (Maximum length of a character string)
Table 9- 47 Maximum length instruction
MAX_LEN(in);
MAX_LEN (Maximum length of string) provides the maximum length value
assigned to string IN at output OUT. If errors occur during processing of the
instruction, then an empty string length will be output.
The String and WString data types contain two lengths: the first byte (or word)
gives the maximum length and the second byte (or word) gives the current
length (this is the current number of valid characters).
• The maximum length of the character string is assigned for each String or
WString declaration in square brackets. The number of bytes occupied by a
String is 2 bytes greater than the maximum length. The number of words
occupied by a WString is 2 words greater than the maximum length.
• The current length represents the number of the characters actually used.
The current length must be less than or equal to the maximum length. The
current length is in bytes for a String and in words for a WString.
Use the MAX_LEN instruction to get the maximum length of the character
string and the LEN instruction to get the current length of a string.