Printer Checks via Inter

 BBS: Inland Empire Archive
Date: 03-29-92 (13:09)             Number: 153
From: MICHAEL MALLEY               Refer#: NONE
  To: MIKE PHILLIPS                 Recvd: NO  
Subj: Printer Checks via Inter       Conf: (2) Quik_Bas
MP>  Hey, can you use interrupts to check the printer status in QuickBASIC
MP>4.5?  I saw this little jewel in the C Echo.  Seems like I remember
MP>interrupts from the QBNews (gotta look in my folder).  Anyone have code?

Hi Mike!  Here's the code to check printer status.  Int 21H, function
44H requires a handle in BX, and I can't remember exactly if you have to
open the printer as a device, or you can use a standard handle.  Never
had to, and unless I researched it I wouldn't be able to tell you
anything as a fact.  Maybe Dave will know for sure.

Regs.ax = &H200
Regs.dx = (0 - 2 for LPT1 - LPT3)
CALL Interrupt(&H17, Regs, Regs)

'Regs.ax returns the printer status in AH.

AH% = Regs.ax \ 256

7 6 5 4 3 2 1 0
              1  Timeout
          x x    Unused
        1        I/O error
      1          Printer selected
    1            Out of paper
  1              Acknowledged
1                Printer not busy

If you're using a Personal Computer AT, a PC XT 286, or a PS/2, and the
printer is busy, it will execute Int 15H function 90H, which is a device
wait.  My guess is that it will wait for a while to get ahold of the
printer.  But if you're printing something, the best thing to do is to
trap the error through BASIC, because someone can always reach over and
turn off the printer resulting in a crashed program.

 * SLMR 2.1a * It's not crippled, it's functionally challenged!

--- Maximus 2.01wb
 * Origin: UltraTech - Nashville, TN  (615) 356-0453 {HST} (1:116/30)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET