vbdpss.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Article Q37031, Example 2
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 Printer Error Can Hang; CALL INTERRUPT to Check Printer, Example 2
 
 The following is a sample BASIC program that uses the CALL INTERRUPT
 routine to check the printer status whenever the F1 key is pressed, or
 after a BASIC error:
 
 Example
 -------
 
 ' 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'
 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