Esta função retorna o comprimento (Expresso em número de caracteres excluindo o terminador) da string definida pelo parâmetro Str.
Função
CoDeSys: eCDSXUnified12Lib
Laboratório de lógica: eLLabXUnified12Lib
descrição
Str (@STRING Ponteiro para a sequência da qual calcular o comprimento.
A função retorna uma variável (UDINT) que indica o número de caracteres na string, excluindo o terminador.
Exemplos
Como usar os exemplos.
O exemplo calcula o comprimento da string 'Hello!'e o número de caracteres que compõem a string é transferido para a variável Length. O resultado do cálculo é 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]