home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / pascal / swag / printing.swg / 0009_PRINTER3.PAS.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-05-28  |  2.2 KB  |  63 lines

  1. Unit Myprint;
  2. {$D-,I-,S-}
  3. Interface
  4.  
  5. Uses Dos;
  6.  
  7. Var
  8.   Prt        : Array[1..2] of Text;
  9.   Lst        : Text Absolute Prt;
  10.  
  11. Function PrinterStatus(p: Byte): Byte;
  12. Function PrinterReady(Var b : Byte; p: Byte): Boolean;
  13.  
  14. Implementation
  15.  
  16. Procedure RawMode(Var L);       { make sure that device is in raw mode }
  17.   Var
  18.     regs : Registers;
  19.   begin
  20.     With regs do begin
  21.       bx   := TextRec(L).Handle;         { place the File handle in bx }
  22.       ax   := $4400;           { setup For Function $44 sub-Function 0 }
  23.       MSDos(regs);                              { execute Dos Function }
  24.       dl   := dl or $20;                            { bit 5 = raw mode }
  25.       dh   := 0;                                      { set dh to zero }
  26.       ax   := $4401;           { setup For Function $44 sub-Function 1 }
  27.       MSDos(regs)                               { execute Dos Function }
  28.     end; { With }
  29.   end; { RawMode }
  30.  
  31. Function PrinterStatus(p: Byte): Byte;
  32.    { Returns the Printer status. LPT1=p=1, LPT2=p=2 }
  33.    Var regs   : Registers; { from the Dos Unit                         }
  34.    begin
  35.      With regs do begin
  36.        dx := p - 1;        { The Printer number                        }
  37.        ax := $0200;        { The Function code For service wanted      }
  38.        intr($17,regs);     { $17= ROM bios int to return Printer status}
  39.        PrinterStatus := ah;{ Bit 0 set = timed out                     }
  40.      end;                  {     1     = unused                        }
  41.    end;                    {     2     = unused                        }
  42.                            {     3     = I/O error                     }
  43.                            {     4     = Printer selected              }
  44.                            {     5     = out of paper                  }
  45.                            {     6     = acknowledge                   }
  46.                            {     7     = Printer not busy              }
  47.  
  48. Function PrinterReady(Var b : Byte; p: Byte): Boolean;
  49.   begin
  50.     b := PrinterStatus(p);
  51.     PrinterReady := (b = $90)         { This may Vary between Printers }
  52.   end;
  53.  
  54. begin
  55.   assign(Prt[1],'LPT1');
  56.   reWrite(Prt[1]);
  57.   RawMode(Prt[1]);
  58.   assign(Prt[2],'LPT2');
  59.   reWrite(Prt[2]);
  60.   RawMode(Prt[2]);
  61. end.
  62.  
  63.