NUM_TO_STRING
Inputs
IN : ANY Input number.
WIDTH : DINT Length of the output string (see remarks).
DIGITS : DINT Number of digits after decimal point.
Outputs
Q : STRING Value converted to string.
Remarks
This function converts any numerical value to a string. Unlike the ANY_TO_STRING function, it allows you to specify a length and a number of digits after the decimal points.
-
If WIDTH is 0, the string is formatted with the necessary length.
Q := NUM_TO_STRING (1.333333, 0, 2); (* Q is '1.33' *)
-
If WIDTH is greater than 0, the string is completed with leading blank characters in order to match the value of WIDTH.
Q := NUM_TO_STRING (123.4, 8, 2); (* Q is ' 123.40' *)
-
If WIDTH is greater than 0, the string is completed with trailing blank characters in order to match the value of WIDTH.
Q := NUM_TO_STRING (123.4, -8, 2); (* Q is '123.40 ' *)
-
If DIGITS is 0 then neither decimal part nor decimal point are added.
Q := NUM_TO_STRING (1.333333, 3, 0); (* Q is ' 1' *)
-
If DIGITS is greater than 0, the corresponding number of decimal digits are added. '0' digits are added if necessary
Q := NUM_TO_STRING (1.333333, 0, 1); (* Q is '1.3' *)
-
If the value is too long for the specified width, then the string is filled with '*' characters.
Q := NUM_TO_STRING (1234, 3, 0); (* Q is '***' *)