Returns the maximum string length
This instruction returns the maximum string length set in the variable declaration from the input variable and writes the value into the output variable.
Input
String variable declared in the POU header
Output
Maximum number of characters of declaration
If this instruction is used with UTF-8 strings, please refer to the notes concerning UTF-8 strings under the data type STRING.
if a string applied at the input or output is an invalid string
if a string applied at the input or output is an invalid string
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
sTestString: STRING[128]:='A better life. A better world';
iStringLength: INT:=0;
iMaxStringLength: INT:=0;
END_VAR
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_F,MAX_LEN!,,20,1,26,3,,?D?C);
B(B_VARIN,,sTestString,18,1,20,3,);
B(B_VAROUT,,iMaxStringLength,26,1,28,3,);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
iMaxStringLength := MAX_LEN(sTestString);