Article ID: 108904
Article Last Modified on 8/16/2005
ON ERROR GOTO bug
OPEN "scrn:" FOR OUTPUT AS #1
PRINT #1, "Printing to screen"
PRINT "Printing to printer"
END
bug:
PRINT #1, "Error number ";ERR
END
Bit Condition ---------------------------------- Bit 7 Printer Not Busy (0 = Busy) Bit 6 Acknowledge Bit 5 Out of Paper Bit 4 Printer Selected Bit 3 I/O Error Bit 2 Unused Bit 1 Unused Bit 0 Timed-OutFor example, to determine if the printer is out of paper, the interrupt could be called and bit 5 could be examined. To call MS-DOS interrupts from Visual Basic for MS-DOS, use the CALL INTERRUPT routine.
' To try this example in VBDOS.EXE:
' 1. From the File menu, choose New Project.
' 2. Copy the code example to the Code window.
' 3. Press F5 to run the program.
'
' To run this program in the environment, you must invoke the
' environment with the /L switch to load the default Quick library:
' VBDOS.EXE /L for Visual Basic 1.0 for MS-DOS
DECLARE SUB PrinterStatus ()
DEFINT A-Z
' Use the following include file for Visual Basic 1.0 for MS-DOS:
REM $INCLUDE: 'VBDOS.BI'
' Use the following include file for QuickBasic for MS-DOS:
REM $INCLUDE: 'qb.bi'
' Use the following include file for Basic PDS for MS-DOS:
REM $INCLUDE: 'qbx.bi'
CLS
ON ERROR GOTO Trap
ON KEY(1) GOSUB CheckPrinter
KEY(1) ON
OPEN "lpt1:" FOR OUTPUT AS #1
FOR i = 1 TO 1000
PRINT #1, "dflkgjsaklfajds;lfk"
NEXT i
END
Trap:
CALL PrinterStatus
INPUT "Hit Any Key to Continue"; a$
RESUME
CheckPrinter:
PRINT "err = "; ERR
CALL PrinterStatus
INPUT "Hit Any Key to Continue"; a$
RESUME
SUB PrinterStatus STATIC
DIM ina AS RegType, outa AS RegType
DIM INFO$(7)
ina.ax = &H200
ina.dx = &H0
CALL INTERRUPT(&H17, ina, outa)
outah = outa.ax \ 256
FOR i = 7 TO 0 STEP -1
result = (outah) AND (2 ^ i)
IF result = 0 THEN
INFO$(i) = "OFF"
ELSE
INFO$(i) = "ON"
END IF
NEXT i
PRINT "Bit 7 - Printer Not Busy : "; INFO$(7)
PRINT "Bit 6 - Acknowledge : "; INFO$(6)
PRINT "Bit 5 - Out of Paper : "; INFO$(5)
PRINT "Bit 4 - Printer Selected : "; INFO$(4)
PRINT "Bit 3 - I/O Error : "; INFO$(3)
PRINT "Bit 2 - Unused : "; INFO$(2)
PRINT "Bit 1 - Unused : "; INFO$(1)
PRINT "Bit 0 - Timed-Out : "; INFO$(0)
END SUB
PRINT "Printing to printer" END PROGRAM >LPT1:
Additional query words: VBmsdos QuickBas BasicCom b_vbmsdos b_quickbas
Keywords: kbprb KB108904