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. |
<Zero option> |
Option that determines the number of leading zeros to be shown.
Default this is set to nozero. |
<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:
|
Remarks
Generally you will format a numeric, signed, financial, or integer to an alpha or string variable.
Example
When in a report:
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 (numvar, onezero)
alphavar2 := format (numvar, allzero, ',', '.')
alphavar3 := format (numvar, nozero, '.', ',')
alphavar4 := format (numvar2, onezero)
alphavar5 := format (numvar2, allzero, ',', '.')
alphavar6 := format (numvar2, nozero)
alphavar7 := format (numvar3, allzero, '.', '''')
print (lay_1)
end_routine
The resulting printout will be as follows:
alphavar2: 0.012,34
alphavar3: 12.34
alphavar4: 0.00
alphavar5: 0.000,00
alphavar6:
alphavar7: 4'567.89