NUM_TO_STRING
Function - Converts a number into string value.
Inputs
Input |
Data type |
Description |
IN |
ANY |
Input number. |
WIDTH |
DINT |
Wished length for the output string (see remarks). |
DIGITS |
DINT |
Number of digits after decimal point. |
Outputs
Output |
Data type |
Description |
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 wished length and a number of digits after the decimal points.
If WIDTH is 0, the string is formatted with the necessary length.
If WIDTH is greater than 0, the string is completed with heading blank characters in order to match the value of WIDTH.
If WIDTH is lower than 0, the string is completed with trailing blank characters in order to match the absolute value of WIDTH.
If DIGITS is lower or equal to 0, then neither decimal part nor point are added.
If DIGITS is greater than 0, the corresponding number of decimal digits are added. '0' digits are added if necessary
If the value is too long for the specified width, then the string is filled with '*' characters.
Examples
Q := NUM_TO_STRING (123.4, 8, 2); (* Q is ' 123.40' *)
Q := NUM_TO_STRING (123.4, -8, 2); (* Q is '123.40 ' *)
Q := NUM_TO_STRING (1.333333, 0, 2); (* Q is '1.33' *)
Q := NUM_TO_STRING (1234, 3, 0); (* Q is '***' *)
NUM_TO_STRING |
IEC 61131-3 Automation platform > Programming - Reference guide > Type conversion functions > NUM_TO_STRING |
Created with the Personal Edition of HelpNDoc: Effortlessly Create High-Quality Help Documentation with a Help Authoring Tool