home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / mike40c / prnchk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-10-24  |  1.3 KB  |  52 lines

  1. #include <dos.h>
  2. #include <keys.h>
  3.  
  4. /*************************************************
  5.   Check printer status and flash message on screen
  6.   if not ready.  User can abort by hitting Esc key
  7.   returning a -1.  Routine will return a 0 when
  8.   printer has been put online and is ready.
  9. **************************************************/
  10. chk_printer()
  11. {
  12.         while ((prtest()) != 0x90) {   /* Check for printer error */
  13.             if (kbhit())
  14.                 if ((getch()) == ESCAPE)   /* Abort if escape is pressed */
  15.                     return(-1);
  16.             prterr();   /* Otherwise flash error message */
  17.         }
  18.      return(0);
  19. }
  20.  
  21.  
  22. prterr()   /* Error message for printer */
  23. {
  24.     char *tscr;
  25.  
  26.     tscr = malloc(4000);
  27.     getscrn(tscr, 0);
  28.     put_screen("                            ", 0x4f, 28, 1,
  29.       25, 11, 0);
  30.     put_screen(" ERROR - Printer not ready! ", 0x4f, 28, 1,
  31.       25, 12, 0);
  32.     put_screen("        ESC to exit         ", 0x4f, 28, 1,
  33.       25, 13, 0);
  34.  
  35.     wait(2);
  36.     putscrn(tscr, 0);
  37.     free(tscr);
  38. }
  39.  
  40.  
  41. prtest()   /* Test for printer status (0x90 is good) */
  42. {
  43.     union REGS REG;
  44.  
  45.     REG.h.ah = 0x2;   /* Function 2 */
  46.     REG.x.dx = 0;     /* First printer number */
  47.     int86(0x17, ®, ®);
  48.     return(REG.h.ah);
  49. }
  50.  
  51.  
  52.