Script functions reference > Script functions in alphabetical order > N > NFormat

NFormat
Syntax
NFormat(format, num);
format
Z – A digit displayed if required. If the value of a leading or trailing digit is zero, the digit is replaced by a space, " ".
B – A digit displayed if required. If the value of a leading or trailing digit is zero, the digit is removed.
9 – A digit that is always displayed.
# – A digit on either side of a decimal separator, or the last sign if no decimal separator exists. The digit is always displayed.
You can use other characters, including space, as separator characters. If only one separator character is specified in the format string, this character is always interpreted as the decimal separator.
For example, NFormat("BBB BB9", 80) will result in 80 000. To have 80 as the result in this example, you can add another group of numbers and separator to the format string, e.g. NFormat("BBB BBB BB9", 80).
Note:
Z and B cannot coexist on the same side of the decimal separator. For example, ZB#.#BZ is not a valid format.
Note:
"#.##" formats the value 0 as an empty string.
num
Description
Converts a number to a string, formatting the string according to the specified format syntax.
Note:
Returns
A string according to the specified format syntax.
Example
$a=1234.5;
$b=nformat("Z,ZZ#.##",$a);
$c=nformat("9999#.##",$a);
$d=nformat("ZZ.ZZ",0);
$e=nformat("ZZ.ZZ",0.07);
Result:
$b="1,234.50"
$c="01234.50"
$d=""
$e=".07"
OpenText StreamServe 5.6.2 Updated: 2018-01-26