Kbase P46176: How to check to see if a printer exists on UNIX before outpu
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/3/2003 |
|
Status: Unverified
GOAL:
How to check to see if a printer exists on UNIX before outputting to it
FIX:
To check to see if a printer exists on UNIX before outputting to it, do the following:
DEFINE VARIABLE cOutputDevice AS CHARACTER NO-UNDO.
DEFINE VARIABLE cPrinter AS CHARACTER NO-UNDO.
DEFINE VARIABLE lFound AS LOGICAL NO-UNDO.
UPDATE cOutputDevice.
INPUT THROUGH "lpstat -s". /* this command may need to be changed */
/* depending on your flavor of unix */
REPEAT:
IMPORT cPrinter.
IF cPrinter BEGINS cOutputDevice THEN
DO:
ASSIGN lFound = TRUE.
LEAVE.
END.
END.
INPUT CLOSE.
IF lFound = FALSE THEN
MESSAGE "Unknown Printer" VIEW-AS ALERT-BOX.
ELSE
/* Code goes here to output to the printer */