format()

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

Syntax

String  format(String fmt) 
  1. fmt is a String defining the string format.

Usage

The syntax of fmt is compatible to the BDL "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, fmt 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("###.##")