FormatNumberForDisplay
(VTScada-Layer function. Must be called with a leading backslash.)
| Description: | Given a numeric value, or numeric text value, returns it as text delineated with thousands-separator commas as required. For example, converts 1000000 to "1,000,000." |
| Returns: | Text |
Usage: ![]() |
Script or steady state. |
| Function Groups: | String and Buffer |
| Related to: | CommaFormat |Format |FormatNumber |
Format: ![]() |
\FormatNumberForDisplay(Value[, Width, Precision]) |
| Parameters: |
| Value |
| Required. Any numeric expression giving the original value to be formatted. |
| Width |
| Optional.* Any numeric expression giving the minimum number of characters to use. If fewer characters are required to produce the output, the area is filled with blank spaces on the left to make up the required number of characters. This is useful for aligning numbers on the right. If more characters are required than the Width parameter specifies, the extra characters are extended to the right. By making Width 0, the output will be aligned on the left. If the Width parameter is greater than or equal to 100, the format of the floating point number used is in the most compact form which may be in exponential form if the exponent is less than -4 or is greater than the specified Precision parameter. The actual width used in this mode is 100 less than the specified Width. Trailing 0s are not displayed in this mode. Values for Width outside the range of 0 to 255 inclusive are invalid. |
| Precision |
| Optional.* Any numeric expression giving the precision of the output (with rounding). The number of digits to appear after the decimal point if Width is less than 100, the maximum number of significant digits to appear, or if Width is greater than or equal to 100. |
| Comments: |
*If Width or Precision are needed, both must be used. The following values are returned unchanged:
When three parameters are supplied, the Value is passed through 'Format(Width, Precision, Value)' before commas are added. When FormatNumbersWithCommas is disabled (set to 0), all values are cast to text and returned without comma formatting. |
Example:
\FormatNumberForDisplay(12345678.25325, 10, 2);
Returns: 12,345,678.25
\FormatNumberForDisplay("123.25", 100, 2);
Returns: 1.2E+02
\FormatNumberForDisplay("3.8E+02");
Returns: "3.8E+02"
\FormatNumberForDisplay("0.000123", 30, 10);
Returns: "0.0001230000"
