Print forms

A print form defines a layout that is sent to a printer.

Print process

Printing is a two-step process:
  • First, you code print statements, each of which adds a form to a runtime buffer
  • Next, the EGL runtime 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
    • The program is in segmented mode (see Segmentation in Text UI programs and UI programs) and runs a converse statement
    • The program was called by a non-EGL (and non-VisualAge Generator) program, and the called program ends
    • The main program in the run unit ends
    • The converseVar.printerAssociation system variable (which assigns an output destination for print forms) is set in a COBOL program that is running on iSeries®.
In the case of multiform output, you must invoke the print statements 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 identifies each item of the order for the company
  • At the bottom of the output, a fixed form indicates the number of screens or pages needed to scroll through the list of items
To print this information, invoke a series of print statements, each of which operates on a print form. Those statements reference the following forms in the order shown:
  1. Top form
  2. Floating form, as presented by a print statement that is invoked repeatedly in a loop
  3. Bottom form

To start a new page, call the converseLib.pageEject() system function 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 converseLib.pageEject() system function 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.

Other considerations

Decimal point and separator characters are determined by the decimalSymbol and separatorSymbol build descriptor options. In EGL programs that you generate for COBOL that do not use print forms, the default values for these options come from the language-dependent options module specified for your runtime installation. However, if you use print forms, the default value for the decimalSymbol option is a period, and the default value for the separatorSymbol option is a comma. If these values are not appropriate to your location, you must explicitly set these build descriptor options.

Print destination

When EGL processes a close statement to present a print form, the output is sent to a printer or data set. You can specify the destination at any of three times:
  • At debug time (for information about the EGL debugger, refer to the EGL Programmer's Guide)
  • At generation time, using a Resource Associations part (for more information, refer to the EGL Generation Guide)
  • At run time, using the current value of the converseVar.printerAssociation system variable (see printerAssociation)

Feedback