PRINT (Print) keyword for display files

You use this file-level or record-level keyword to specify that the workstation user can press the Print key to print the current display.

See System/36 environment considerations for display files for special considerations when you specify the PRINT keyword in files that are used in the System/36 environment.

The format of the keyword is:
PRINT[(response-indicator ['text']) ∨ (*PGM) ∨
  ([library-name/]printer-file-name)]

The following four examples illustrate the four ways you can specify the PRINT keyword:

Further considerations of the ways to specify the PRINT keyword are discussed in the following sections.

If you specify the PRINT keyword in any form, the workstation user can print a display containing the message help. In this case, the print operation is performed as if the PRINT keyword were specified with no parameters.

PRINT keyword without parameter values for the local workstation

The IBM i operating system spools the output to the specified printer file (which can be defined through DDS or on the PRTFILE parameter on the CRTDEVDSP or CHGDEVDSP commands).

Nondisplay fields appear as blanks. Duplicated characters entered by pressing the Dup key appear as asterisks (*). Display attributes appear as blanks. If the print function cannot be performed successfully, the IBM i operating system attempts to complete the print function using the printer file specified on the PRTFILE parameter on the CRTDEVDSP or the CHGDEVDSP command that is used to describe the display device to the system.

For workstation printers attached through the workstation controller, a message indicating that there is a problem is sent to the workstation user requesting the print function. The workstation user can make the printer ready or press the Reset key. To cancel a print request before it is complete, the workstation user can press and hold the Shift key, then press the Print key.

Note: After the current display is printed, the paper is advanced twice the number of lines as in the current display size (48 lines for a 24 x 80 display, and 54 lines for a 27 x 132 display).

PRINT keyword without parameter values for the remote workstation

The IBM i program attempts to print the display image on the associated workstation printer without sending the data through the system. The associated workstation printer is the printer device specified on the PRINTER parameter of the CRTDEVDSP or CHGDEVDSP command that is used to describe the local display device to the system.

If the printer is not ready when the Print key is pressed, no specific message is sent to the user. The workstation requesting the print function remains inoperable until the printer is made ready, or until the print request is canceled (by using the shifted Print key).
Note: After the current display is printed, the paper is advanced the same number of lines as in the current display size (24 lines for a 24 x 80 display, and 27 lines for a 27 x 132 display).

Option indicators are valid for this keyword.

Example: PRINT keyword with no parameter values

The following example shows how to specify the PRINT keyword with no parameter values.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A                                      PRINT
00020A          R RECORD1
     A

Example: PRINT keyword with a response indicator or *PGM special value

If you specify the PRINT keyword with a response indicator, the IBM i operating system returns control to your program with the specified response indicator set on. No data is received from the device. The keyboard is locked until your program sends another output operation to the display file. There is no difference in the print function between local and remote workstations. If you specify *PGM, the IBM i operating system returns control to your program. The only difference between these two forms is the response indicator; all other processing is the same.

The optional text for the response indicator form is included on the computer printout created at program compilation time to explain the intended use of the indicator. This text functions only as a comment. The single quotation marks are required. If you specify more than 50 characters between the single quotation marks, the text is truncated to 50 characters on the program computer printout.

The following example shows how to specify the PRINT keyword with a response indicator.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A                                      PRINT(01 'User presses Print key')
00020A          R RECORD1
     A

The following example shows how to specify the PRINT keyword with the *PGM special value.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A                                      PRINT(*PGM)
00020A          R RECORD1
     A

Example: PRINT keyword with a specified printer file

The IBM i program reads the display buffer and prints the display image using the specified printer file. The printer file that you specify as a parameter value for this keyword can be either an externally described or a program-described file. It also can be either spooled or nonspooled. If you specify an externally described printer file, it must contain a record format with the same name as the file.

The printer file must exist and be authorized to the user of the display when the Print key is pressed. This also applies to the library name if it is specified. If the IBM i operating system is unable to perform the print function on the specified printer file, it attempts to use the printer file specified on the PRTFILE parameter of the CRTDEVDSP or the CHGDEVDSP command. SPOOL(*YES) should be specified on the CRTPRTF or CHGPRTF command to prevent the keyboard from locking.

If you do not specify the library name, the current library list at program run time is used.

The following example shows how to specify that the display is to be directed to printer file, LIB1/PRINTFILE1.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A                                      PRINT(LIB1/PRINTFILE1)
00020A          R RECORD1
     A