LEN block
Short summary
Name |
LEN |
→POU type |
|
Category |
|
Conform to →IEC-standard |
currently restricted
|
Graphical interface |
|
Available since |
version 1.30.0 (for logi.CAD 3) |
Functionality
The block determines the length of a string.
At input IN, enter the string for which the length should be determined.
logi.CAD 3 determines the character positions within a string as follows: 1, 2, ..., n. 1 corresponds to the leftmost character position and n to the length of the string.
Three-character combination of the dollar sign ($) followed by two hexadecimal digits are evaluated as single character. Example: The string '$B15' (corresponds to '±5') consists of 2 characters. See →character string literal for more examples for those combinations.
Inputs, return value
|
Identifier |
Description |
|
Inputs: |
IN |
STRING |
input value |
Return value: |
– |
USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_INT) |
|
Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
Example for usage within ST-editor
PROGRAM Test
VAR
result1, result2, result3, result4 : INT;
END_VAR
result1 := LEN(IN :=
'ASTRING'
); (* The variable
'result'
evaluates to
'7'
. *)
result2 := LEN(IN :=
'$B15'
); (* The variable
'result'
evaluates to
'2'
. *)
result3 := LEN(IN :=
'ABC$00D'
); (* The variable
'result'
evaluates to
'3'
. Reason: The character string is terminated at position
4
because of
'$00'
. *)
result4 := LEN(IN :=
''
); (* The variable
'result'
evaluates to
'0'
. *)
END_PROGRAM
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.