Introduction

Language Structure

IB Statements

File System

Comet 32 Runtime

Index

Edit mask

The edit-mask parameter in a FORMAT statement is used for formatted output of numeric fields. The edit mask itself may be a string constant or variable. If it is a string constant, it must be enclosed in quotation marks. If it is a string variable, its value must be set in the Procedure Division of the program.

Edit masks determine how a numeric field will be formatted during output. If no edit mask is specified, Internet Basic supplies a default edit mask: leading zeros are suppressed, a decimal point is printed along with all leading and trailing zeros to the right of the decimal point, and a trailing minus sign is printed for negative values.

User-supplied edit masks may contain three parts: a leading character, the body characters, and trailing characters.

The optional leading character, actually a floating lead character, may be a dollar sign or left parentheses:

Leading character Purpose
$ Prints a dollar sign immediately before the first non-zero digit in the numeric field. The dollar sign floats from left to right, according to the location of the first non-zero digit.
( Prints left parentheses immediately before the first non-zero digit in the numeric field only if the field contains a negative value. The left parenthesis must be paired with a matching right parenthesis as the trailing character.

The body characters of an edit mask specify the digits, decimal point, and commas in the numeric value. The following characters may be used:

Body characters Purpose
0 Represents a single digit of the numeric field. Prints zeros if the digit is zero-valued (including leading zeros), or digits 1 through 9 according to the value of the numeric field.
# Also represents a single digit of the numeric field. Prints digits 0 through 9 according to the value of the numeric field, but DOES NOT print leading zeros.
* Represents a single digit of the numeric field. Prints an asterisk in that position if the value of that position is zero. Used for asterisk fill of leading zeros.
. Separates integer portion of the numeric field from the decimal portion. Prints a decimal point in that position. Note: The decimal point cannot be used as the last character in an edit mask.
, Separates groups of digits on the left side of the decimal point. Prints a comma in that position. Will not print if leading characters are zero.

Two basic rules determine the operation of edit masks:

  1. The first "digit character" in the body of the edit mask 0, #, or * is used as the "fill character."

    The fill character fills from the left of the numeric field to the first non-zero position.

    If the edit mask is a string variable, the fill character may be virtually any character (other than a comma or decimal point).

  2. The significant starting position is determined by either: a. the first non-zero digit in the data (from the left), or

    b. the first position after the first 0 in the edit mask.

Edit masks must contain a trailing character. The following options are available:

Trailing character Purpose
+ Prints a plus sign after positive numbers, or a minus sign after negative numbers. Always prints a sign.
- Prints a trailing blank after positive numbers, or a minus sign after negative numbers.
DR Prints DR after positive numbers, or CR after negative numbers. Indicates "debit" or "credit."
CR Prints two blanks after positive numbers, or CR after negative numbers.
) Prints a right parenthesis after negative numbers, a blank space after positive numbers. Must be paired with a left parenthesis leading character.

Examples:

Also see
additional edit mask examples.
1. #,##0.00-

   a.   no leading character
   b.   body characters for a 6.2 number
   c.   suppress leading zeros (and comma)
   d.   start printing leading zeros at the decimal point
   e.   print decimal point
   f.   print two digits after decimal point
   g.   print trailing minus sign on negative numbers

2. $*##,##0.00-

   a.   floating dollar sign
   b.   asterisk fill
   c.   start printing zeros at the decimal point
   d.   print decimal point
   e.   print two digits after the decimal point
   f.   print trailing minus sign on negative numbers

3. (###,##0.00)

   a.   print parentheses around negative values
   b.   suppress leading zeros
   c.   start printing zeros at the decimal point
   d.   print decimal point
   e.   print two digits after the decimal point