Text() Function
- Last UpdatedFeb 21, 2017
- 1 minute read
The Text() function returns the value of a number as a string according to a specified format. You may want to do this to format a value in a certain way or to combine the result with other string values for further processing.
Syntax
result = Text (number, format)
Parameters
number
A literal numeric value, analog tagname, or numeric expression.
format
Use "#", "0", ".", or ",".
Use "#" to represent a digit, "." to represent the decimal separator, "0" to force a leading zero, and "," to insert a comma.
If you use a zero in the format, it must be followed by zeros. All places to the right of the decimal point must always be zeros. For example, 000.00 is correct, while #0#0.0# is incorrect.
The function rounds the value, if necessary. A literal string, message tagname, or string expression.
Example(s)
Text(66,"#.00") returns "66.00".
Text (1234,"#") returns "1234".
Text (123.4, "#,##0.0") returns "123.4".
Text (12.3, "0,000.0") returns "0,012.3".
Text(3.57,"#.#") returns "3.6".
This script returns the string "Reactor Pressure is 1690.3 mbar" if the analog tagname "pressure" contains the value 1690.2743.
"Reactor Pressure is "+Text(pressure,"#.#")+" mbar"