Print — Mask


Numeric masks

You can always use the size word to set the width of a column, but the mask can also be padded with spaces to set the column width. Leading spaces in a numeric mask are stripped from the right and added to the left (since numeric numbers are generally right justified).

Characters that are used in the mask for numeric fields include:

  • “#” — (pound sign). Each “#” character is replaced with the corresponding number in the field value. If the mask does not include decimal places and the field value is decimal, the resulting field value will be rounded to the nearest integer.
  • “,” — (comma) separates the value into thousands, millions, etc.
  • “-“ — (hyphen or minus sign) at the end of the mask forces a negative value to print the minus sign at the end of the field.
  • “$” — (dollar sign) prints a dollar sign to the left of the number
  • “(“ — (left parenthesis) encloses a negative numeric value with left and right parentheses. The right parenthesis is optional, not required in the mask.

Here are some examples:

  • field1 mask “####” — each “#” character is replaced with the corresponding value
    • 1234 prints     1234
    • -1234 prints     -1234
    • 1234.500 prints    1235  (rounded to nearest integer).
  • field1 mask “####-“ — forces the minus sign on negative numbers to print on the right side.
    • 1234 prints    1234
    • -1234 prints    1234-
  • field1 mask “#####,###” — by including a comma, the field will be separated by thousands, millions, etc.
    • 123456 prints    123,456
    • -123456 prints    -123,456
    • 12345678 prints    12,345,678  (even though there is only one comma in the mask, the comma will be supplied for the millions).
  • field1 mask “$##,###” — dollar sign will precede the value.
    • 123456 prints    $123,456
  • field1 mask “(##,###,###)” — for negative values, the parentheses will replace the minus sign.
    • -1234567 prints    (1,234,567)

 

Page 1 — mask
Page 2 — the asterisk
Page 3 — numeric masks
Page 4 — decimal masks
Page 5 — date mask

Next – Decimal mask >

Leave a Reply