STRING_TO_UINT

STRING (decimal format) into unsigned INTEGER

STRING_TO_UINT converts a string in decimal formal into a value of the data type Unsigned INTEGER.

First, the string is converted into a value of the data type STRING[32], which is subsequently converted into a value of the data type UINT in a subprogram with approximately 270 steps. The subprogram is also used by the functions STRING_TO_INT, STRING_TO_WORD, STRING_TO_UDINT and STRING_TO_DWORD.

Parameters

Input

Unnamed input (STRING)

Input data type

Output

Unnamed output (UINT)

Conversion result

Remarks

Acceptable Format:

'[Space][Sign][Decimal number][Space]', e.g. ' 123456 '

Acceptable characters:

  • Space

    Space “

  • Sign

    "+“ (plus), "-" (minus)

  • Decimal Number

    Decimal numbers "0“ - "9“

The analysis ends with the first non-decimal number.

Example

POU headerCopy code to clipboard

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
		UINT_value: UINT:=0;
		STRING_value: STRING[8]:='543';
	END_VAR

LD bodyCopy code to clipboard

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_VARIN,,STRING_value,13,2,15,4,);
B(B_VAROUT,,UINT_value,24,2,26,4,);
B(B_F,STRING_TO_UINT!,Instance,15,2,24,4,,?D?C);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST bodyCopy code to clipboard

UINT_value:=  STRING_TO_UINT(STRING_value);

Modified on: 2019-01-24Feedback on this pagePanasonic hotline