Chapter 8 Logic Instructions
8-293
FB/FC
FC
LEN calculates the number of characters in a string.
Parameters
Meaning
Description Valid range
In String Input String
Depends on the data type of the
variable that the input parameter is
Out
Number of
characters
Output
Number of
characters
Depends on the data type of the
variable that the output parameter is
Boolean
Bit string Integer
Real
number
Time, date
String
BOOL
BYTE
WORD
LWORD
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
TIME
TOD
STRING
In
●
Out
●
Note:
The symbol ● indicates that the parameter is allowed to connect to the variable or constant of the data
type.
Function Explanation
The LEN instruction finds the number of characters in a string and the result is output to Out. For
example, when the string is ABCDEFGH, the value of Out is 8.
Precautions for Correct Use
The input variables are not allowed to omit. An error will occur during the compiling of the software if
the input variables are omitted. But the output variable is allowed to omit.
Programming Example
The LEN_In string is ’AaBbCcDd’. As LEN_EN is TRUE, the value of Out1 is 8.
The variable table and program
Variable name Data type Current value
1
LEN
EN ENO
In Out
LEN_EN
LEN_In Out1