Consultor Eletrônico



Kbase P8604: How to send PCL command escape sequences to your printer in 4GL?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   21/04/2005
Status: Verified

GOAL:

How to print using Normal, Compressed, Portrait or landscape modes in 4GL?

FIX:

The following code was tested on HP LaserJet 4Si. For other printers, consult the printer?s programming manual for its command escape sequences.

/******* HP LaserJet 4Si Mode exercising procedure ******/
DEFINE VARIABLE CompressedMode AS CHARACTER FORMAT "X(09)" INITIAL "~033(s16.66H".
DEFINE VARIABLE NormalMode AS CHARACTER FORMAT "X(09)" INITIAL "~033(s10H".
DEFINE VARIABLE LandscapeMode AS CHARACTER FORMAT "X(05)" INITIAL "~033&l1O".
DEFINE VARIABLE PortraitMode AS CHARACTER FORMAT "X(05)" INITIAL "~033&l0O".
DEFINE VARIABLE ResetDefaultMode AS CHARACTER FORMAT "X(02)" INITIAL "~033E".

/* Set sesson output to printer */
OUTPUT TO PRINTER.

/* Select and set the Printer density mode */
MESSAGE
"Do you want to print in Compressed mode?"
VIEW-AS ALERT-BOX BUTTONS YES-NO UPDATE Compressed AS LOGICAL.
IF Compressed THEN
PUT CONTROL CompressedMode.
ELSE
PUT CONTROL NormalMode.

/* Select and set the Page Orientation mode */
MESSAGE
"Do you want to print in Landscape Mode?"
VIEW-AS ALERT-BOX BUTTONS YES-NO UPDATE Landscaped AS LOGICAL.
IF Landscaped THEN
PUT CONTROL LandscapeMode.
ELSE
PUT CONTROL PortraitMode.

/* Print something to test the printer settings */
DISPLAY PROGRAM-NAME(1) FORMAT "x(70)".
FOR EACH Customer WHERE Cust-Num < 70 NO-LOCK:
DISPLAY Customer.Cust-Num Customer.Country.
END.

/* Restore printer default settings */
PUT CONTROL ResetDefaultMode.

/* Restore session output to default */
OUTPUT CLOSE.
/*** End of HP LaserJet 4Si Mode exercising procedure ***/