PRODUCT : TURBO BASIC NUMBER : 431 VERSION : 1.1 OS : PC-DOS DATE : APRIL 4, 1989 PAGE : 1/2 TITLE : CHECKING PRINTER STATUS This program shows you how to obtain the status of the printer using the REG and CALL INTERRUPT statements. PRINTER SERVICES - (copied from page 239 of The Peter Norton Programmer's Guide To The IBM PC) Send one byte to printer : Interrupt Registers (hex) Input Output Description --- ----------------- ----------- 17 AH=00 AH=success/failure Status bit setting: AL=character status code 0=time out DX=printer number 1=unused 2=unused 3=1:I/O error 4=1:selected 5=1:out of paper 6=1:acknowledge 7=1:not busy Initialize printer: 17 AH=01 AH=status code Status code bit settings: DX=printer number see printer service 00 Get printer status: 17 AH=02 AH=status code Status code bit setting: DX=printer number see printer service 00 ================================================================= --- MAIN PROGRAM --- CLS CALL CheckPrinter END 'End of program '------------------- SUB CheckPrinter REG 1, &H0200 'load the AH register with 02 REG 4, &H0000 'Load the DX register with 0 CALL INTERRUPT &H17 'Invoke interrupt 17 hex IF HEX$(REG(1)) = "9000" THEN 'If status bits 4 and 7 are PRODUCT : TURBO BASIC NUMBER : 431 VERSION : 1.1 OS : PC-DOS DATE : APRIL 4, 1989 PAGE : 2/2 TITLE : CHECKING PRINTER STATUS 'set PRINT "PRINTER IS READY" The following message covers all other status conditions such as OUT OF PAPER and OFF LINE. The reason for using one message to cover all other status conditions is that various printers return different values for an OUT OF PAPER or an OFF LINE condition. For example, hex values returned for an OFF LINE condition include: 'C000,2800,8800,8000 depending on the printer being used. ================================================================= ELSE PRINT "PRINTER IS NOT READY" PRINT "Value returned is ";HEX$(REG(1)) SELECT CASE HEX$(REG(1)) These are the values returned for a Panasonic KX-1092i or equivalent printer. The values you use may have to be modified depending on the printer being used. CASE "800" PRINT "A Panasonic KX-1092i or equivalent printer is offline" CASE "F800" PRINT "A Panasonic KX-1092i or equivalent printer is off" CASE "2800" PRINT "A Panasonic KX-1092i or equivalent printer is out of paper"; PRINT "and off line" CASE "B800" PRINT "A Panasonic KX-1092i or equivalent printer is out of paper"; PRINT "and on line" END SELECT END IF END SUB