tips:revmedia:r27

Switching Printers In Revelation

Published ByDateVersionKnowledge LevelKeywords
Revelation Technologies31 AUG 19891.1XEXPERTPDISK, PRINTING, SETPTR, PRINTER

Many applications require the use of two printers attached to one workstation. Commonly, preprinted forms or labels will be loaded in one printer, and blank paper or letterhead will be loaded in the other. Since DOS allows the setup of multiple printers as LPT1, LPT2, LPT3, etc., the application developer can formulate a methodology to print the proper information to the proper printer.

This has been a challenge for both Revelation and Advanced Revelation application developers. The goal of this bulletin is to provide an easy and efficient solution to this problem.

PDISK is a utility used in Advanced Revelation to redirect printer output to a file. PDISK has two components:

  1. PDISK, the R/BASIC user interface.
  2. SETPTR, the assembly language code that does printer redirection.

The standard PDISK user interface can be used to select a printer device by entering the following command at TCL or via a PERFORM or EXECUTE from an R/BASIC program:

PDISK LPT1

PDISK will then check to see if LPT1 exists. Since LPT1 is a DOS device, PDISK will find it and ask if LPT1 should be overwritten. Respond "Yes" and PDISK will redirect printer output to LPT1, or the specified line printer.

This approach requires no R/BASIC code, but is cumbersome as it requires the user to respond each time the printer is redirected.

Because SETPTR is stored in the VERBS file, it can be called directly, avoiding the need for user interaction. The calling parameters are:

SETPTR(DEVICE,ACTION.FLAG)

Where:

  • DEVICE: the device name in an ASCIIZ string (terminated with an ASCII character 0).
  • ACTION.FLAG: when set true, this flag tells SETPTR to overwrite the device/file.

The program fragment illustrated in Figure 1 will accomplish the same as the previous PDISK command without user intervention.

A generic subroutine callable from any program is illustrated in Figure 2. This routine could be called from any R/BASIC program by cataloging it in the VOC file or copying it to the VERBS file.

Figure 1

DECLARE SUBROUTINE SETPTR

DEVICE = 'LPT1':\00\           ;* load device, terminate with char(0)
ACTION.FLAG = 1                ;* overwrite device handle
SETPTR(DEVICE,ACTION.FLAG)     ;* redirect

Figure 2

SUBROUTINE SELECT.PRINTER(DEVICE,FLAG)
DECLARE SUBROUTINE SETPTR,MSG

* DEVICE = name of printer: LPT1, LPT2
* FLAG = return status: 1 if good redirection, 0 if problem
*
FLAG = 0 ;* set flag to false

* check device to see if it is a print device
IF DEVICE[1,3] = 'LPT' OR DEVICE[1,3] = 'PRN' THEN
   * check last char of device to see if it is char(0)
   DEVICE = TRIMB(DEVICE)
   IF DEVICE[-1,1] NE CHAR(0) THEN
      * add char(0) if not there
      DEVICE = TRIMB(DEVICE):CHAR(0)
   END
   * set action flag to overwrite file/device.
   ACTION.FLAG = 1
   * call routine to redirect printer
   SETPTR(DEVICE,ACTION.FLAG)
   BEGIN CASE
     CASE ACTION.FLAG = 21
       * good redirection tell calling program
       FLAG = 1
     CASE ACTION.FLAG < 20
       MSG('DOS error ':ACTION.FLAG,'','','')
     CASE ACTION.FLAG <> 21
       MSG('Undefined Error ':ACTION.FLAG,'','','')
   END CASE
END
RETURN
  • tips/revmedia/r27.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1