Sysstrlen, longueur de la chaîne

Liste

Cette page fait partie de la Manuel de programmation CEI 61131-3. Aller à l'index.

Cette fonction renvoie la longueur (Exprimé en nombre de caractères sans le terminateur) de la chaîne définie par le paramètre Str.

Cercle d'informations

Fonction

CODESYS : eCDSXUnified12Lib

LogicLab : eLLabXUnified12Lib

Description

Str (@STRING Pointeur sur la chaîne pour calculer la longueur.

La fonction retourne une variable (UDINT) qui indique le nombre de caractères dans la chaîne sans le terminateur.

Image de la fonction système

Exemples

Comment utiliser les exemples.
L'exemple calcule la longueur de la chaîne 'Hello!'et le nombre de caractères qui composent la chaîne est transféré à la variable Length. Le résultat du calcul est 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]
Cet article a-t-il été utile?