STRING_TO_REAL
The STRING_TO_REAL block converts a STRING value to REAL.
Ladder Representation
Block Structure
| Variable Type | Name | Data Type | Description |
|---|---|---|---|
| VAR_INPUT | EN | BOOL | Block enable. |
| VAR_INPUT | STR | STRING | STRING value. |
| VAR_OUTPUT | DONE | BOOL | End of operation. |
| VAR_OUTPUT | OUT | REAL | REAL 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
| Device | Version |
|---|---|
| PLC300 | 2.10 or later |
Execution Flowchart

Examples
- Ladder
- Structured Text
The Ladder examples show different STRING-to-REAL conversions. Each successful operation sets DONE after the conversion finishes.
The conversion shown above completed successfully. The minus sign and the base-10 exponent indicator e are valid mathematical characters.
The conversion shown above did not complete successfully. The first character was not identified as mathematically valid, so the output was reset to zero.
The following Structured Text code applies the same logic shown in the Ladder example.
VAR
STR : STRING := '105p0';
OUT : REAL;
END_VAR
OUT := FB_STRING_TO_REAL(EN := DI1, STR := STR, DONE => DO1);