INT_TO_STRING_LEFT_ALIGNED

INTEGER into left aligned STRING

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

Parameters

Input

Unnamed input (INT)

input data type

Output

Unnamed output (STRING)

conversion result

Remarks

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

Function used

String1 defined as

Result

String1:=INT_TO_STRING_LEFT_ALIGNED(-12345)

STRING[1]

'-'

STRING[2]

'-1'

STRING[3]

'-12'

STRING[4]

'-123'

STRING[5]

'-1234'

STRING[6]

'-12345'

STRING[7]

'-12345'

STRING[8]

'-12345'

and so on...

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
		iValue: INT:=-12345;
			(*example value*)
		sResult: STRING[8]:='';
			(*result: here '-12345'*)
	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,INT_TO_STRING_LEFT_ALIGNED!,,11,1,26,3,,?D?C);
B(B_VARIN,,iValue,9,1,11,3,);
B(B_VAROUT,,sResult,26,1,28,3,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

sResult:= INT_TO_STRING_LEFT_ALIGNED(iValue);

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