STRING_TO_LREAL

STRING into LREAL

STRING_TO_LREAL converts a string in floating-point format into a value of the data type LREAL.

Thereby the attached string is first converted into a value of the data type STRING[64]. Finally this is converted into a value of the data type LREAL via a sub-program that requires approximately 580 steps.

Unnamed input (STRING)

Input data type

Output

Unnamed output (LREAL)

Conversion result

Remarks

Permissible format: '[Space][Sign][Decimal numbers].[Decimal numbers][Space]' e.g. ' 1.45620752 '

Permissible characters:

Space

Space ""

Decimal numbers

Decimal numbers "0"-"9"

The analysis ends with the first non-decimal number.

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
		lrValue: LREAL:=0.0;
		bStart: BOOL:=FALSE;
		sValue: STRING[64]:='';
	END_VAR

LD body

When the variable bStart is set to TRUE, the function is carried out.

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_CONTACT,,bStart,3,2,5,4,);
B(B_F,E_STRING_TO_LREAL!,,10,1,20,5,,?DEN?D?AENO?C);
B(B_VARIN,,sValue,8,3,10,5,);
B(B_VAROUT,,lrValue,20,3,22,5,);
L(1,0,1,6);
L(1,3,3,3);
L(5,3,10,3);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (bStart) then
    lrValue:=STRING_TO_LREAL(sValue);
end_if;

Modified on: 2022-08-23Feedback on this pagePanasonic hotline