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 uses the values of the DBFORMAT and DBMONEY environment variables.

Table 1. Formatting symbols for numeric data
Character Description
* Represents a digit. Fills with asterisks any position that would otherwise be blank.
& Represents a digit. Fills with zeros any position that would otherwise be blank.
# Represents a digit. If no digit is to be displayed at that position, the # is replaced by a blank.
< 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("###.##")