WINPRINT-SET-MARGINS

This operation code allows you to set the margins on a report.

Usage

CALL "WIN$PRINTER"
    USING WINPRINT-SET-MARGINS, WINPRINT-DATA
    GIVING RESULT

Parameters

WINPRINT-DATA Group item defined in winprint.def as follows:
01 WINPRINT-DATA.
   03 WPRTDATA-SET-STD-FONT.
   03 WPRTDATA-MARGINS REDEFINES
      WPRTDATA-SET-STD-FONT.
      05 WPRTDATA-TOP-MARGIN           PIC 9(7)V99 COMP-5.
      05 WPRTDATA-BOTTOM-MARGIN        PIC 9(7)V99 COMP-5.
      05 WPRTDATA-LEFT-MARGIN          PIC 9(7)V99 COMP-5.
      05 WPRTDATA-RIGHT-MARGIN         PIC 9(7)V99 COMP-5.
      05 WPRTDATA-MARGIN-UNITS         UNSIGNED-SHORT.
Note: This group item should be initialized before it is used.

Description

When combined with the ability to set the exact height of a line (see WINPRINT-SET-LINES-PER-PAGE), this operation lets you reliably print on pre-printed forms with many different devices. WINPRINT-SET-MARGINS sets the margins for the next report if the printer is not open, or for the current report if the printer is open. If the printer is open and the current page is blank, the margin change occurs for the current page. Otherwise, the margin change occurs on the next page.

Note: Most printers have minimum margins that cannot physically be printed in, regardless of the setting of the logical margins.

Setting Margins

The four margin fields should be set to the values you want to use. For example, to set half-inch top and bottom margins you would move .5 to WPRTDATA-TOP-MARGIN and WPRTDATA-BOTTOM-MARGIN. You can set a margin to zero to use the printer's default margins.

Note: This operation calculates the printable area of a report when determining the capacity for lines or columns. Setting a value for WPRTDATA-RIGHT-MARGIN does not cause the print line to be truncated.

Before you can set the margins, the MARGIN-UNITS field must be set to a level 78 that describes the measurement units. The choices are:

WPRTMARGIN-DEFAULT-MARGINS Use printer default margins (this is the default).
WPRTMARGIN-PIXELS Margins expressed in printer-dependent units. Laser printers, for example, use either 300 or 600 units per inch.
WPRTMARGIN-CELLS Margins expressed as a number of rows or columns based on the currently selected font.
WPRTMARGIN-INCHES Margins expressed in inches.
WPRTMARGIN-CENTIMETERS Margins expressed in centimeters.

To use the margin-setting feature to simplify printing on pre-printed forms, we suggest this sequence:

  1. Establish which printer you want to use.
  2. Select the font.
  3. Set the margins.
  4. Set the line height.

It is important to note that step (3) should precede step (4) because the line height depends on the top and bottom margins that you have set. For an 11" form, a typical scenario might be:

Font: Courier New, 12 point
Margins: .5" top and bottom
Lines per page: 60

This would result in 6 lines per inch with 3 blank lines at the top and bottom of each page. The code to set the margins for this case would be:

INITIALIZE WPRTDATA-MARGINS
MOVE .5 TO WPRTDATA-TOP-MARGIN, WPRTDATA-BOTTOM-MARGIN
MOVE WPRTMARGIN-INCHES TO WPRTDATA-MARGIN-UNITS
CALL "WIN$PRINTER" USING WINPRINT-SET-MARGINS, 
      WINPRINT-DATA