Every online Easytrieve screen has two jobs: show the operator information and collect what they type. Output handling is the show half. It covers the display-only fields that present names, balances, dates, headings, totals, and status messages the program computes or reads from files. In a SCREEN activity the runtime paints these fields onto a 3270 map and transmits it to the terminal; your BEFORE-SCREEN procedure fills the field values just before that paint. Beginners often confuse output with input, forget to refresh fields between cycles, or leave numeric values unformatted so balances read as long digit strings. This page explains protected attributes, where to load values, MASK formatting, highlighting with intensity and color, refreshing state between cycles, and how output fields relate to the file and working-storage data behind them.
An output field is one the operator reads but does not change. A customer name pulled from a master file, a running balance you calculated, or an error message all belong on output fields. An input field, by contrast, is where the operator types—an account number to look up or an amount to post. The difference is enforced by the field attribute in the screen definition: output fields are protected, input fields are unprotected. Marking a field protected keeps the cursor from landing on it and stops accidental overtyping, which is essential when the value is something your program owns rather than something the operator supplies.
| Attribute | What it does | When to use |
|---|---|---|
| Protected | Operator cannot type into the field; cursor skips it | Names, balances, computed totals, messages |
| High intensity | Displays brighter/bold to draw attention | Totals, warnings, section headings |
| Normal intensity | Standard brightness for routine data | Most read-only detail values |
| Color (where supported) | Assigns a color such as red or green | Red errors, green confirmations on color terminals |
| Nondisplay | Field occupies space but is not visible | Hidden control values or masked sensitive data |
Attribute names and exact spellings vary by Easytrieve release and by whether the field is painted through the SCREEN statement or a screen field definition. Treat the table above as the concept map; confirm the precise keyword your site uses in the SCREEN statement reference before coding, because an unsupported attribute keyword causes a compile error rather than a silent fallback.
Output fields do not fill themselves. The BEFORE-SCREEN procedure runs once per display cycle, immediately before the runtime builds and transmits the map, which makes it the natural place to move data into every output field. A typical inquiry screen reads a record and moves its columns into the matching display fields so the operator sees fresh data each time the screen appears.
12345678910111213BEFORE-SCREEN. PROC GET CUSTOMER-FILE IF EOF CUSTOMER-FILE SCR-NAME = SPACES SCR-BALANCE = 0 SCR-MSG = 'NO MORE CUSTOMERS' EXIT END-IF SCR-NAME = CUST-NAME SCR-CITY = CUST-CITY SCR-BALANCE = CUST-BALANCE SCR-MSG = SPACES END-PROC
Notice that both the success path and the end-of-file path set every output field. On the EOF branch the code blanks the name, zeroes the balance, and sets a message, so the operator never sees leftover values from the previous customer. This discipline of always assigning output fields is the single most important habit in screen output handling.
The runtime does not clear output fields for you between cycles. Whatever you moved into SCR-BALANCE last time is still there next time unless you overwrite it. That behavior is helpful when a value should persist, but harmful when it should not. Two rules keep screens honest: reload any field whose source could have changed, and explicitly clear any field that has no value in the current context. Working-storage fields defined with a RESET attribute may reinitialize at activity boundaries, but do not rely on RESET to scrub per-cycle output—assign values yourself in BEFORE-SCREEN.
Raw numeric fields display as unbroken digit strings, so a balance of 1234567 with two implied decimals looks like 1234567 rather than 12,345.67. A MASK (edit pattern) inserts the punctuation humans expect. The mask defines where commas, the decimal point, a currency symbol, and sign handling appear. Applying a mask affects only how the value is shown; the underlying numeric field keeps its true value for any arithmetic you perform.
| Stored value | Displayed with mask | Purpose |
|---|---|---|
| 1234567 (2 decimals) | 12,345.67 | Money with thousands separators and decimal point |
| -5000 | 5,000- | Trailing sign for negative balances |
| 7 | 007 | Zero-filled fixed-width counter |
| 0 | blank or 0.00 | Suppress or show zero depending on mask choice |
Exact mask characters depend on the Easytrieve release and whether you use a named MASK defined in the Library or an inline edit pattern. The key beginner takeaway is that display formatting is separate from the value itself, and you should format money and counts on screen the same way you would on a printed report.
Not all output deserves equal weight. A grand total, an overdue warning, or an error message should stand out. High-intensity and, on capable terminals, color attributes let you signal importance without changing the data. A common convention is high intensity for totals and headings, red for errors, and green for success confirmations. Keep the scheme consistent across screens so operators learn it. Avoid over-highlighting: if everything is bright, nothing stands out.
123456789BEFORE-SCREEN. PROC PERFORM LOAD-ACCOUNT IF SCR-BALANCE LT 0 SCR-MSG = 'ACCOUNT OVERDRAWN' * paint SCR-MSG with a high-intensity / red attribute ELSE SCR-MSG = SPACES END-IF END-PROC
Screen output fields are display copies, not the master data. When you move CUST-BALANCE into SCR-BALANCE, you create a snapshot for that cycle. If another transaction changes the master record, the screen shows the value only as fresh as your last GET. For inquiry screens this is usually fine. For screens that also update, re-read the record in AFTER-SCREEN before applying changes so you are working against current data, and reload output fields in BEFORE-SCREEN so the operator sees the result. Keeping display fields and master fields clearly named—SCR- prefixes for screen copies—prevents accidental edits to the wrong one.
Think of the screen as a whiteboard the teacher shows the class. Output handling is the teacher writing today's answers on the board before turning it around. Some spots on the board are covered with tape so kids cannot scribble on them—those are the protected output areas. Before each new question the teacher wipes the board and writes the new answers, so nobody sees yesterday's. Important answers get underlined so everyone notices. The real answer key stays in the teacher's folder; the board is just a copy for looking at.
1. Output-only fields on a screen are typically:
2. Where do you normally load values into output fields?
3. A MASK on a numeric output field controls:
4. If an output field shows stale data from the prior record, the likely cause is:
5. Display intensity or color attributes are used to: