Progress
Language Tutorial
for Character


Using PUT for Printer Control

When you send output to a printer, you may want to modify the way the printer generates that output. Many printers have a set of control sequences you can use to specify different print characteristics. You might, for example, want to change the number of printed characters per inch.

When you write a procedure that sends output to a printer, you can include printer control sequences within that procedure. Many control sequences involve special characters that can be represented by their octal (base 8) equivalent. To distinguish these octal codes, you precede the three octal digits by an escape character. Progress then converts the octal number to a single character.

On UNIX, the escape character is a tilde (~) or a backslash (\).

The PUT statement with the CONTROL option allows you to specify a control sequence to send to the printer. This is a partial syntax for this version of the PUT statement.

SYNTAX
PUT [ STREAM stream-name ] 
  CONTROL "ctrl-sequence" "ctrl-sequence" ... 

The control sequences you send to the printer have no effect on the current line, page counters, and positions maintained within Progress. Assume you want to print a report on your Brand X printer, using compressed-print mode.

The following procedure implements this task:

lt-10-13.p
      /**********  DEFINE WIDGETS  **********/
/*1*/  DEFINE VARIABLE Start-Compress AS CHARACTER 
      INITIAL "~033[3w".
/*2*/  DEFINE VARIABLE Stop-Compress AS CHARACTER
        INITIAL "~032[3w".
      DEFINE BUTTON b-normal LABEL "Print Normal Report".
      DEFINE BUTTON b-compress LABEL "Print Compressed Report".
      DEFINE BUTTON b-exit LABEL "Exit".

      /**********  DEFINE FRAMES  **********/
      DEFINE FRAME Frame1
          SKIP(1)
         b-normal b-compress SKIP(1)
          b-exit
            WITH NO-BOX CENTERED THREE-D.

        /**********  DEFINE TRIGGERS  **********/        
/*3*/  ON CHOOSE OF b-normal
       DO:
          OUTPUT TO PRINTER.
         FOR EACH Customer WHERE Balance >= 1400 
              WITH STREAM-IO:
              DISPLAY Name Phone Balance Sales-rep.
          END.
          OUTPUT CLOSE.
       END.
/*4*/  ON CHOOSE OF b-compress
       DO:
          OUTPUT TO PRINTER.
          PUT CONTROL Start-Compress.
          FOR EACH Customer WHERE Balance >= 1400 
              WITH STREAM-IO:
             DISPLAY Name Phone Balance Sales-rep.
           END.
          PUT CONTROL Stop-Compress.
          OUTPUT CLOSE.
      END.

      /**********  MAIN LOGIC  **********/
      ENABLE ALL WITH FRAME Frame1.
      WAIT-FOR CHOOSE OF b-exit. 

NOTE: This procedure works only if you have a printer connected to your system. Not all printers support compressed printing.

These notes help to explain the code:

  1. The start-compress variable contains the four-character sequence that puts the printer into compressed-print mode. These four characters are octal 033 (decimal 27) followed by left bracket ([), 3, and w.
  2. The variable stop-compress takes the printer out of compressed print mode.
  3. When the user selects btn-normal, Progress runs the report in normal mode.
  4. When the user selects btn-compressed, Progress runs the report in compressed mode.

Control sequences are hardware-dependent, thus applications containing hard-coded printer control sequences are not easily portable to other environments. See the Progress Client Deployment Guide for more information about using the PUT CONTROL statement with control sequences.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095