DINT_TO_STRING_LEFT_ALIGNED

DOUBLE INTEGER into left-aligend STRING

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

Parameters

Input

DINT

Input data type

Output

STRING

Conversion result

Explanation

Function used

String1 defined as

Result

String1:= DINT_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
		diInputValue: DINT:=12345678;
		sResult: STRING[11]:='';
	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,DINT_TO_STRING_LEFT_ALIGNED!,,14,1,30,3,,?D?C);
B(B_VARIN,,diInputValue,12,1,14,3,);
B(B_VAROUT,,sResult,30,1,32,3,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

sResult:=DINT_TO_STRING_LEFT_ALIGNED(diInputValue);

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