Print forms
Forms and their types are introduced in Form part. The current page outlines how to present print forms.
Print process
Printing is a two-step process:
- First, you code print statements, each of which adds a form to a run-time buffer
- Next, the EGL run time adds the symbols needed to start a new page, sends all the buffered forms to a print device, and erases the contents of the buffer. Those services are provided in response to any of the following circumstances:
- The program runs a close statement on a print form that is destined for the same print device; or
- The program is in segmented mode (as described in Segmentation) and runs a converse statement; or
- The program was called by a non-EGL (and non-VisualAge Generator) program, and the called program ends; or
- The main program in the run unit ends.
In the case of multiform output, the print statements must be invoked in the order in which you want to present the forms. Consider the following example:
- At the top of the output, a fixed form identifies a purchasing company and an order number
- In a subsequent floating area, a series of identically formatted floating forms identify each item of the company's order
- At the bottom of the output, a fixed form indicates the number of screens or pages needed to scroll through the list of items
You can achieve that output by submitting a series of print statements that each operate on a print form. Those statements reference the forms in the following order:
- Top form
- Floating form, as presented by a print statement that is invoked repeatedly in a loop
- Bottom form
The symbols needed to start a new page are inserted in various circumstances, but you can cause the insertion by invoking the system function sysLib.pageEject before issuing a print statement.
Considerations for fixed forms
The following statements apply to fixed forms:
- If you issue a print statement for a fixed form that has a starting line greater than the current line, EGL inserts the symbols needed to advance the print device to the specified line. Similarly, if you issue a print statement for a fixed form that has a starting line less than the current line, EGL inserts the symbols needed to start a new page.
- If a fixed form overlays some but not all lines in another fixed form, EGL automatically inserts the symbols needed to start a new page and places the second fixed form on the new page.
- If a fixed form overlays all lines in another fixed form, EGL replaces the existing form without clearing the rest of the output from the buffer. To keep the existing output and place the new form on the next page, invoke the system function sysLib.pageEject before issuing the print statement for the new form.
Considerations for floating forms
The following mistakes can occur if you are using floating forms:
- You issue a print statement to place a floating form beyond the end of the floating area; or
- You issue a print statement that at least partially overlays a floating area with a fixed form, then issue a print statement to add a floating form to the floating area.
The result in either case is that EGL inserts the symbols needed to start a new page, and the floating form is placed on the first line of the floating area on the new page. If the page is similar to the order-and-item output described earlier, for example, the new page does not include the topmost fixed form.
Print destination
When EGL processes a close statement to present a print file, the output is sent to a printer or data set. You can specify the destination at any of three times:
- At test time (as described in EGL debugger)
- At generation time (as described in Resource associations and file types)
- At run time (as described in relation to the system variable sysVar.printerAssociation)
Related concepts
EGL debugger
FormGroup part in EGL source format
Form part in EGL source format
Form part
Resource associations and file types
Segmentation in text applications
Related reference
sysLib.pageEject
sysVar.printerAssociation