home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP15.EXE / CHP1521.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  1.9 KB  |  73 lines

  1. /*
  2.    Listing 15.21. Printer error handling function.
  3.    Author: Craig Yellick
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11.  
  12. function PrintError(r, c, err, passAlong)
  13. /*
  14.    Error handler used during printing.
  15.  
  16.    r           Row to display messages.
  17.    c           Column to display messages.
  18.    err         Error object to handle.
  19.    passAlong   Handler to pass error object along to
  20.                if this handler can't deal with it.
  21. */
  22. #include "ERROR.CH"
  23. local tryAgain
  24.  
  25.   //  If generic code indicates a printer error
  26.   if err:genCode = EG_PRINT
  27.  
  28.     /*
  29.        Display informative message and wait for either
  30.        the printer to come back on-line or a keystroke.
  31.     */
  32.     set device to screen
  33.     @ r, c clear to r +2, maxCol()
  34.     @ r, c    say "Printer Error!"
  35.     @ r +1, c say ;
  36.       "Possible problems: Out of paper, jammed, off-line."
  37.     @ r +2, c say ;
  38.       "Attempt to fix problem.  Press any key to continue."
  39.     keyboard ""
  40.     do while .not. (isprinter() .or. inkey() <> 0)
  41.     enddo
  42.  
  43.     /*
  44.        If the printer comes back, ask if they want to resume.
  45.     */
  46.     @ r, c clear to r +2, maxCol()
  47.     if isprinter()
  48.       @ r,    c say "Printer is back..."
  49.       @ r +1, c say "Do you want to resume printing the report?"
  50.       @ r +2, c say ;
  51.         "Press Y to resume printing or any other key to cancel."
  52.       keyboard ""
  53.       tryAgain := (chr(inkey(0)) $ "Yy")
  54.       @ r, c clear to r +2, maxCol()
  55.       if tryAgain
  56.         set device to printer
  57.         return .t.
  58.       endif
  59.     endif
  60.     break
  61.  
  62.   /*
  63.      Some other kind of error occurred, pass the error
  64.      along to the previous error handler.
  65.   */
  66.   else
  67.     return eval(passAlong, err)
  68.   endif
  69.  
  70. return nil
  71.  
  72. // end of file CHP1521.PRG
  73.