UDINT_TO_STRING_LEFT_ALIGNED

Unsigned DOUBLE INTEGER into left-aligned STRING

It converts a value of the data type UDINT into a value of the data type STRING in left-aligned decimal representation.

Parameters

Input

UDINT

Input data type

Output

STRING

Conversion result

Remarks

Explanation

Function used

String1 defined as

Result

String1:=

UDINT_TO_STRING_LEFT_ALIGNED(-12345678)

STRING[2]

'-1'

STRING[4]

'-123'

STRING[6]

'-12345'

STRING[8]

'-1234567'

STRING[10]

'-12345678'

STRING[12]

'-12345678'

and so on...

NOTE

When using the data type STRING with small PLCs like FP-e or FP0, make sure that the length of the result string is equal to or greater than the length of the source string.

Example

POU header

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
		udiValue: UDINT:=12345678;
			(*example value*)
		sResult: STRING[11]:='';
			(*result: here '12345678'*)
	END_VAR

LD body

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,UDINT_TO_STRING_LEFT_ALIGNED!,,15,2,31,4,,?D?C);
B(B_VARIN,,udiValue,13,2,15,4,);
B(B_VAROUT,,sResult,31,2,33,4,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

sResult:=UDINT_TO_STRING_LEFT_ALIGNED(udiValue);

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