This function returns the length (Expressed in number of characters excluding the terminator) of the string defined by the parameter Str.
Function
CODESYS: eCDSXUnified12Lib
LogicLab: eLLabXUnified12Lib
Description
Str (@STRING Pointer to the string of which to calculate length.
The function returns a variable (UDINT) which indicates the number of characters in the string excluding the terminator.
Examples
How to use the examples.
The example calculates the length of the string 'Hello!'and the number of characters that make up the string is transferred to the variable Length. The result of the calculation is 6.
LogicLab (Ptp116)
PROGRAM ST_Sysstrlen
VAR
Length : ARRAY[ 0..1 ] OF UDINT; (* String length *)
DString : STRING[ 32 ] := 'Hello!'; (* Data string *)
END_VAR
// *****************************************************************************
// PROGRAM "ST_Sysstrlen"
// *****************************************************************************
// It's calculated the length of a given string.
// -----------------------------------------------------------------------------
Length[0]:=Sysstrlen(ADR('Hello!'));
Length[1]:=Sysstrlen(ADR(DString));
// [End of file]
CODESYS (Ptp161)
PROGRAM ST_Sysstrlen
VAR
Length : ARRAY[ 0..1 ] OF UDINT; //String length
DString : STRING[ 32 ] := 'Hello!'; //Data string
END_VAR
// *****************************************************************************
// PROGRAM "ST_Sysstrlen"
// *****************************************************************************
// It's calculated the length of a given string.
// -----------------------------------------------------------------------------
Length[0]:=Sysstrlen(ADR('Hello!'));
Length[1]:=Sysstrlen(ADR(DString));
// [End of file]