Formatting Dollar Amounts

Using conversions to format dollar amounts is a typical example. The Attribute Definition item for AMOUNT (amount of sale) in the ORDERS dictionary contains a conversion to produce a formatted dollar amount:

>LIST-ITEM DICT ORDERS 'AMOUNT'

 

   AMOUNT

001   A

002   0

003   AMOUNT

004

005

006

007   MR2$

008   A;N(QTY)*N(PRICE)

009   R

010   10

The conversion MR2$ specifies the format of the dollar amount. The M specifies that numeric data is being converted. The format of the amount is specified as:

Assume, then, that the price of an item is stored as cents. Multiplying by the quantity will produce a result in cents. If this result is 1100, the above conversion will produce a result of:

$11.00

If an INFO/ACCESS report included the AMOUNT attribute, the conversion code would ensure that all of the dollar amounts were right-justified and, therefore, properly lined-up.

Note that the amount of sale is actually derived by a correlative that multiplies the attribute QTY by the attribute PRICE. This correlative is discussed in the Manipulating Existing Data section.

See Also

MX and MY Codes

Stored Format and Output Format

Formatting Dates and Times