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 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.
. (period) Defines the position of the decimal separator. Only a single decimal separator may be specified.
- Displays a minus sign for negative numbers.
( 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("###.##")