Re: On Error Goto Printer

 BBS: Inland Empire Archive
Date: 04-10-92 (22:39)             Number: 170
From: BEN KAHN                     Refer#: NONE
  To: MICHAEL POKRIEFKA             Recvd: NO  
Subj: Re: On Error Goto Printer      Conf: (2) Quik_Bas
** I Heard Michael Pokriefka Say To Ben Kahn **

MP>  BK> not be able to read it.  If you want the code to ask bios for
MP>  BK> printer info, write back.  I don't feel like putting it in.

     Ugh.  I just looked at the code.  Oh well.  First, I'd
just like to say that the PC Magazine book called BASIC:
Techniques and Utilities is where I got the code from.
It's a great book, but it's expensive ($34!).  Well, I said
I'd type out the code dor you if you asked sooo...

Please note: THIS CODE NEEDS THE LIBRARY QB.QLB TO BE
LOADED IF IT IS RUN IN THE EDITOR.  TO DO THIS TYPE: C:\>QB
/L

DEFINT A-Z
DECLARE SUB INTERRUPT (IntNo, InRegs AS ANY, OutRegs AS ANY)
DELCARE SUB FUNCTION LPTReady% (LPTNumber)

'$INCLUDE: 'REGTYPE.BI'
 ' REGTYPE.BI will by after this note.

LPTNumber = 1

IF LPTReady%(LPTNumber) THEN
     PRINT "The printer is on-line and ready to go."
ELSE
     PRINT "Sorry, the printer is not available."
END IF
END

FUNCTION LPTReady% (LPTNumber) STATIC

     DIM Regs AS RegType                       'For CALL INTERRUPT
     LPTReady% = 0                             'assume not ready

     Address = &H477 + LPTNumber               'LPT timeout address
     DEF SEG = 0                               'access segment zero
     OldValue = PEEK(Address)                  'save current setting
     POKE Address, 1                           'one retry

     Registers.AX = 32                         'first print a space
     Registers.DX = LPTNumber - 1              'convert to 0-based
     CALL INTERRUPT(&H17, Regs, Regs)          'print the space

     Result = (Regs.AX \ 256) OR 128           'get AX, ignore busy
     Result = Result AND 191                   'and acknowledge
     IF Result = 144 THEN                      'it worked!
          Registers.AX = 8                     'print a backspace
          CALL INTERRUPT(&H17, Regs, Regs)     '  to undo the space
          LPTReady% = -1                       'return success
     END IF

     POKE Address, OldValue

Whew!  I don't want to do that again!  Well, here comes REGTYPE.BI.

TYPE RegType
     AX AS INTEGER
     BX AS INTEGER
     CX AS INTEGER
     DX AS INTEGER
     BP AS INTEGER
     SI AS INTEGER
     DI AS INTEGER
     Flags AS INTEGER
     DS AS INTEGER
     ES AS INTEGER
END TYPE

Well, that's it.  You just need to grab it, and paste it to a file.  I HOPE
you can use it.  If you can't well...  I just hope someone
else can.  I'm saveing this message to a file so I can
easily paste it back up if need be.

                                        -Ben

---
 * Origin: Paradise Theatre ][ BBS - 203-949-1691 (1:141/828)
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