LEN block

Short summary

Name

LEN

→POU type

→function

Category

IEC-block, String

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/error.svg currently restricted
(IEC demands data type ANY_STRING for the input, hence the following data type is demanded as well: WSTRING. Currently, this data type is not supported for the block.)

Graphical interface

images/download/thumbnails/414782730/LEN-version-1-modificationdate-1535104503197-api-v2.png

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.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg 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

→Data type

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.

See:

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.