String to Integer
Description of Function
The String to Integer function can be used to convert a
string consisting of numbers into an integer value. This
can then be used like any other integer within your
program such as a new set point, timer value, etc. The
function is capable of converting a 16-bit SIGNED integer
in the range of -32768 to 32767.
Example:
Figure 60 - String To Integer Configuration
The above configuration would convert the numeric value
of a string stored in VB0, VB1, VB2, VB3, and VB4.
01: Flag is set to On when a message is received.
02: Flag value indicates the status of the connection to the
broker. ‘7’ indicates the PLC is Subscribing successfully to
the broker. See Publish Status codes for further details.
03: A VD and VW block showing the value as a number of
the string received from the broker.
04: The VB blocks show the string received from the
broker as ASCII values, 1=49, 2=50, 3=51, etc.
If the string received from the MQTT broker was “12321”
then this would be converted to a numeric value of 12321.
If the string received from the MQTT broker was greater
than 32767 or less than -32768, then the string will be
converted to a meaningless value. If the string received
was a character, a through z, then this will be converted
to a value of ‘0’.