Storage and display are different problems. A packed salary field stores nybbles efficient for arithmetic; a report row should show commas, decimal point, dollar sign, or credit indicator for humans. The MASK parameter on DEFINE attaches an edit pattern to a field name so LINE, TITLE, and DISPLAY format output without changing bytes on disk. MASK accepts a literal in quotes with digit placeholders, optional mask identifier letters A through Y for reuse, BWZ to blank zero amounts, and HEX for hexadecimal debug view. Wrong mask—too few nines for field width—truncates printed columns. Wrong mask on alphabetic field fails or misleads. This page teaches edit mask characters, standard patterns for money phone and date, negative indicators, default system masks for quantitative fields, and identifier reuse across large Library dictionaries.
On DEFINE: MASK followed by optional identifier letter, optional BWZ, quoted literal, or HEX keyword. Examples: MASK '$$,$$9.99', MASK M 'Z9/99/99', MASK BWZ, MASK HEX. Multiple options combine per documentation—BWZ with literal suppresses all-zero formatted output entirely.
12345PAY-GROSS 94 4 P 2 MASK '$$,$$9.99' PHONE W 10 N MASK '(999) 999-9999' HIRE-DATE 136 6 N MASK Z 'Z9/99/99' DEBUG-FLD W 2 P MASK HEX ZERO-SUP W 5 P 2 MASK BWZ '$$,$$9.99'
| Character | Meaning | Effect |
|---|---|---|
| 9 | One digit from field | 999 formats three digits |
| Z | Digit with leading zero suppress | Z9 shows 7 not 07 |
| * | Asterisk replaces leading zeros | Credit protection checks |
| $ | Floating currency symbol | Before first nonzero digit |
| - | Minus before first nonzero | Negative indicator |
| , | Comma at mask position | Suppressed if value too small |
Every digit in numeric field must have corresponding mask character—nine or Z typically. Literal punctuation like slashes and parentheses prints at fixed mask positions. Commas suppress when value magnitude does not reach that grouping level per Getting Started rules.
Standard money mask '$$,$$$,$$9.99' with optional CREDIT or minus at end for negative values. Protected check amount pattern '*,***,***,999.99-' uses asterisks for leading digit protection. BWZ on payroll exception lines hides zero adjustments readers might misinterpret as missing data versus intentional zero.
| Mask literal | Used for |
|---|---|
| '(999)999-9999' | Telephone number |
| '999-99-9999' | Social Security style grouping |
| 'Z9/99/99' | Date with slashes |
| '$$,$$$,$$9.99 CREDIT' | Money with credit word |
| '-,---,--9.99' | Negative number with commas |
Mask all digit positions first, then append negative indicator at right end—minus sign, CR for credit, or DB for debit per shop standard. Indicator prints only when value negative. Field with contents -012345678 and mask ending in minus produces formatted negative display without separate IF logic on reports.
First field MASK M '$$,$$9.99' registers mask under letter M. Later field MASK M alone retrieves same pattern without repeating literal—reduces Library size and ensures consistent payroll formatting across dozens of amount fields. Do not assign different literals to same letter in one program. Options table may predefine site-standard mask letters.
BWZ suppresses entire formatted output when field is all zeros—useful for optional columns on dense reports. Combine BWZ with literal mask. BWZ alone also valid per DEFINE documentation. Stored value remains zero—only print line blank. IF logic still sees zero unless you also use BWZ-style display semantics only on output path.
HEX displays contents in double-digit hexadecimal—essential for packed and binary debugging. Up to fifty bytes. Not allowed on VARYING fields. Pair with DISPLAY in test jobs before promoting FILE layout changes. Alphanumeric fields may use HEX where numeric masks invalid.
Quantitative fields with decimal positions receive system default edit masks—commas and decimal point on totals. PAY value 1000 on P 7 2 may print with default pattern per documentation table. Override when business requires credit indicators or floating dollar signs default lacks.
Assignment and file READ change stored bytes. MASK never alters storage—only output formatting path. Assigning edited display back from report to field requires separate unedit logic—not automatic reverse of mask. Report writers format at print time from raw numeric internal form.
MASK is a stencil you lay on top of a number when showing it to people. The number in the box stays the same, but the stencil adds dollar signs, commas, and slashes so it looks like a check or phone number. BWZ means if the number is all zeros, show nothing—leave the line blank instead of printing zero dollars.
1. MASK on DEFINE primarily affects:
2. Character 9 in a numeric edit mask means:
3. BWZ on MASK means:
4. MASK HEX displays field as:
5. Mask identifiers A through Y allow: