AnyLEN

AnyLEN 1:

The function AnyLEN with the return type INT determines the described length of a string variable. This is applied to input STR of type ANY and can thus be analyzed.

For string variables, fixed memory areas are reserved depending on the declaration, but these are usually only partially filled with a text.

If the created variable is of type STRING, the memory area in which the variable is located is searched byte by byte until a byte with the value "0" is found, i.e. the end of the filling text is reached. The return value of the function is equal to the number of bytes searched, excluding the "0" found.

If no byte with the value "0" is found, a text fills the entire area of the string, the return value of the function then corresponds to the memory size of the created string in bytes.

If the created variable is not of type STRING, the memory size of the variable in bytes is assigned to the return value of the function.

Syntax

FUNCTION AnyLEN : INT
VAR_INPUT
  STR    : ANY;
END_VAR

AnyLEN 2: Inputs

Name

Type

Description

STR

ANY

Variable to be examined. In principle, any simple variable type can be created here.

Requirements

Development environment

Required PLC library

TwinCAT 3.1 4024.35

Tc3_BA2_Common from V2.1.20.0