Skip to main content

STRING_TO_REAL

The STRING_TO_REAL block converts a STRING value to REAL.

Ladder Representation

STRING_TO_REAL Ladder representation

Block Structure

Variable TypeNameData TypeDescription
VAR_INPUTENBOOLBlock enable.
VAR_INPUTSTRSTRINGSTRING value.
VAR_OUTPUTDONEBOOLEnd of operation.
VAR_OUTPUTOUTREALREAL value.

Operation

When EN is TRUE, the block reads STR character by character, converts the valid numeric sequence to REAL, and stores the result in OUT.

If the first character is not mathematically valid, OUT receives zero. If valid characters are found, conversion continues until the end of the STRING or until an invalid character is found.

When EN is FALSE, OUT remains unchanged and DONE remains FALSE.

The DONE output indicates that the operation has finished.

Compatibility

DeviceVersion
PLC3002.10 or later

Execution Flowchart

STRING_TO_REAL execution flowchart

Examples

The Ladder examples show different STRING-to-REAL conversions. Each successful operation sets DONE after the conversion finishes.

STRING_TO_REAL Ladder example

STRING_TO_REAL Ladder example result

STRING_TO_REAL additional Ladder example

The conversion shown above completed successfully. The minus sign and the base-10 exponent indicator e are valid mathematical characters.

STRING_TO_REAL additional Ladder example

The conversion shown above did not complete successfully. The first character was not identified as mathematically valid, so the output was reset to zero.

STRING_TO_REAL additional Ladder example