format()

Converts the numeric value to a string representation defined by a format string.

Syntax

format("format-string") 

Usage

The format string syntax is compatible to the D4GL "USING" format string. The formatting takes the values of the environment variables DBFORMAT and DBMONEY into account.

Table 1. Formatting symbols
Character Description
* Fills with asterisks any position that would otherwise be blank.
& Fills with zeros any position that would otherwise be blank.
# This does not change any blank positions in the display.
< Causes left alignment.
, (comma) Defines the position of the thousands separator. The thousands separator is not displayed if there are no digits to the left. By default, the thousands separator is a comma, but it can be another character as defined by DBFORMAT.
. (period) Defines the position of the decimal separator. Only a single decimal separator may be specified. By default, the decimal separator is a period, however it can be another character as defined by DBMONEY or DBFORMAT.
- Displays a minus sign for negative numbers.
$ This is the placeholder for the front specification of DBMONEY or DBFORMAT.
( Displayed as left parentheses for negative numbers (accounting parentheses).
) Displayed as right parentheses for negative numbers (accounting parentheses).

Example

For DECIMAL and FLOAT data types, format-string consists of pound signs (#) that represent digits and a decimal point. This code formats the numeric value of the overall total as a string, producing three places to the left of the decimal point and exactly two places to the right:

overalltotal.format("###.##")