AMT Help Files

FORMAT

Syntax

Command
Mandatory parameter
Optional parameter
Mandatory keyword
Optional keyword

<Data item> := FORMAT (<Numeric data>[, <Zero option>[, <Decimal character>, <Thousand character>]])

Description

This command is used to control how a numeric is shown (formatted) in the output.

Diagram

Returned value type

String

Parameters

Parameter Description
<Data item> Alpha or String that will collect the formatted data.
<Numeric data>

Numeric value.

Literals, variables and routine results are allowed.
Expressions are not allowed to be used directly as numeric value.

<Zero option>

Option that determines the number of leading zeros to be shown. 

  • "nozero", no zero will be displayed for the numeric value. 
  • "onezero", one zero will only be shown if the value is zero.
  • "allzero", and the value contains less characters then the value length supports, the value is completed with leading zeros until the full value length is displayed.

Default this is set to nozero.

When left blank it will check the setting in the application options.

<Decimal character> Character that overrides the default decimal point character and forces inclusion of decimal point and decimal part. (allowed are . and ,)

When left blank it will check the form options, when those are left blank it reverts back to the application options.
<Thousand character> Separator to be used between every three digits counted from the right in numeric values. 
Allowed characters are . (period) , (comma) and ' (apostrophe).
Note: To specify that an apostrophe should be used, four single quotation marks in a row should be typed. See the alphavar7 assignment in the example below.

The default is no separator/blank.

The format command used in global routines no longer inherits decimal signs directly from the application options.

The following applies:

  • If no decimal separator is specified, it will inherit from the global routine options.
  • If the global routine decimal sign option is set to default, it will inherit from the calling form/report.
  • If the calling form/report decimal sign option is also set to default, it will inherit from the application.

Remarks

Generally you will format a numeric, signed, financial, or integer to an alpha or string variable.

Example

When in a report:

begin_definitions
var
    numvar    : numeric 6.2 value 0012.34
    alphavar1 : alpha 10
    alphavar2 : alpha 10
    alphavar3 : alpha 10

    numvar2   : numeric 6.2 value 0000.00
    alphavar4 : alpha 10
    alphavar5 : alpha 10
    alphavar6 : alpha 10

    numvar3   : numeric 6.2 value 4567.89
    alphavar7 : alpha 10
end_definitions

routine main
begin_routine
    alphavar1
 := format (numvaronezero)
    alphavar2 := format (numvarallzero',''.')
    alphavar3 := format (numvarnozero'.'',')

    alphavar4 := format (numvar2onezero)
    alphavar5 := format (numvar2allzero',''.')
    alphavar6 := format (numvar2nozero)

    alphavar7 := format (numvar3allzero'.''''')
    print (lay_1)
end_routine

The resulting printout will be as follows:

alphavar1: 12.34
alphavar2: 0.012,34
alphavar3: 12.34

alphavar4: 0.00
alphavar5: 0.000,00
alphavar6:

alphavar7: 4'567.89

 

Return to

Commands