Changing the default printer
To change the default printer for the session, you can use the PRINTER–NAME option of the SESSION statement as shown in the i-wchpr.p procedure.
i-wchpr.p
/*1*/ DEFINE VARIABLE printername AS CHARACTER NO-UNDO.
/*2*/ printername = SESSION:PRINTER-NAME.
/*3*/ SESSION:PRINTER-NAME = "\\AB1\hplaser".
/*4*/ OUTPUT TO PRINTER.
FOR EACH Customer NO-LOCK:
DISPLAY Customer.Name SPACE Customer.Balance.
END.
/*5*/ SESSION:PRINTER-NAME = printername.
|
To change the default printer:
1. Create a variable for the output of SESSION:PRINTER–NAME.
2. The SESSION:PRINTER–NAME attribute returns the name of the default printer.
3. The SESSION:PRINTER–NAME attribute sets another printer, \\AB1\hplaser, as the default printer.
4. The OUTPUT TO PRINTER prints the report on the printer \\AB1\hplaser.
5. The SESSION:PRINTER–NAME attribute restores the original default printer.