VA FileMan V. 22.0 Programmer Manual Banner


Main Chapter Getting Started Manual Advanced User Manual

Classic VA FileMan API

COMMA^%DTC: Number Format

Formats a number to a string that will separate billions, millions, and thousands with commas.

Input Variables

(Required) The number you want to format. X may be positive or negative.


(Optional) The number of decimal digits you want the output to have. If X2 is not defined, two decimal digits are returned. If X2 is a number followed by the dollar sign (e.g., 3$) then a dollar sign will be prefixed to X before it is output.


(Optional) The length of the desired output. If X3 is less than the formatted X, X3 will be ignored. If X3 is not defined, then a length of twelve is used.

Output Variable

The initial value of X, formatted with commas, rounded to the number of decimal digits specified in X2. If X2 contained a dollar sign, then the dollar sign will be next to the leftmost digit. If X was negative, then the returned value of X will be in parentheses. If X was positive, a trailing space will be appended. If necessary, X will be padded with leading spaces so that the length of X will equal the value of the X3 input variable.


Example 1

 >S X=12345.678 D COMMA^%DTC

The result is:

X="  12,345.68 "

Example 2

>S X=9876.54,X2="0$" D COMMA^%DTC

The result is:

X="     $9,877 "

Example 3

>S X=-3,X2="2$" D COMMA^%DTC

The result is:

X="     ($3.00)"

Example 4

>S X=12345.678,X3=10 D COMMA^%DTC

The result is:

X="12,345.68 "


Reviewed/Updated: March 8, 2007