Path: utzoo!attcan!uunet!mcvax!weijers From: weijers@cwi.nl (Eric Weijers) Newsgroups: comp.lang.pascal Subject: Re: How to check for printer line status ? Message-ID: <383@piring.cwi.nl> Date: 24 Jun 88 17:21:54 GMT References: <13936@santra.UUCP> Organization: CWI, Amsterdam Lines: 62 In article <13936@santra.UUCP> k34386t@kaira.UUCP (Petri Kruiseri Suominen) writes: > > >Does anyone know how to check for printer line status with TP4, >I've tried the following, but the result is just the same as with >no check at all, PC just waits for the printer to become online. > > >function checkprn:boolean; >var > lst:text; >begin > assign(lst,'LPT1'); > {$I-} > rewrite(lst); > {$I+} > if IOresult<>0 then > checkprn:=false > else > checkprn:=true; >end; You should use DOS interrupt $17 (HEX). Define a variable of type registers and set AH to 2 and DX to the number of the printer you want to test. If you have only one printer, DX should be 0. If the interrupt returns, the AH register contains the printer status byte. This byte is build up as follows: bit 0 : time out bit 1 : unused bit 2 : unused bit 3 : I/O error (if set) bit 4 : selected (if set) bit 5 : out of paper (if set) bit 6 : acknowledge (if set) bit 7 : not busy (if set) The code should look like this: uses DOS; var Regs : registers; i : byte; begin i := 1; Regs.AH := 2; Regs.DX := 0; repeat Intr($17,Regs); inc(i); until ((Regs.AH <> 2) or i=10); { here you should test on the value of Regs.AH } end; Eric Weijers weijers@cwi.nl