← Strings and Text

Two Numbers From a Reply

medium

Reads a setpoint and an actual value from a controller reply such as 'fg500-34900'.

What it teaches

STOD reads the first number it finds and stops, so it reads 500 from 'fg500-34900' and never reaches 34900. The second number has to be taken out of the text after the separator before it is converted, without the '-', or STOD reads '-34900' as minus 34900. A reply without the '-', such as 'fg500', is not valid, and STOD of text with no digits gives 0, which looks like a real reading.

Parameters

TagDirectionTypeDefaultDescription
Out_SetpointOutputDINT0The number before the dash
Out_ActualOutputDINT0The number after the dash
Sts_ValidOutputBOOL0The reply has a dash
Ref_ReplyInOutSTRING—A controller reply such as 'fg500-34900'

Required behavior