Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!ugle.unit.no!solan1.solan.unit.no!fredrik From: fredrik@solan.unit.no (Fredrik Knoph Kvamme) Newsgroups: comp.sys.ibm.pc.misc Subject: Re: Printing with Pascal 5.5 Message-ID: <1991Mar15.001849.25830@ugle.unit.no> Date: 15 Mar 91 00:18:49 GMT References: <3235@crdos1.crd.ge.COM> Sender: news@ugle.unit.no Reply-To: fredrik@solan.unit.no (Fredrik Knoph Kvamme) Organization: Norwegian Institute of Technology Lines: 61 In article <3235@crdos1.crd.ge.COM>, @crdgw1.ge.com:erwvegm@cs.vu.nl (exos:) writes: |> |> Hi, |> Is there somebody out there who can tell me how I can |> check if there is a printer connected to lpt1 and ,if so, |> if it's on-line when I'm using 'Turbo Pascal 5.5' ? The easiest way to check if there is a printer connected to LPT1 is to check the hardware directly. The parallell port has three I/O ports. port 378h Is the data port. It's value is sent directly to the port. It can be read in order to verify what you have written or to make the parallellport work as a two way interface. port 379h Status from the printer. 0 x 1 x 2 x 3 Error (0=printer error) 4 Select (1=printer online) 5 Paper (1=printer out of paper) 6 Ack (0 acknowledge pulse, 1 normal input) 7 BUSY (0=printer is busy, do not send more data) port 37Ah Control lines to printer 0 Strobe (strobe bit to one to output data to printer) 1 Autofeed (1=automatic line feed after CR) 2 Init (Pulse bit to zero to initialize printer) 3 Select (Allways 1 so printer reads output) 4 Enable int (1=IRQ7 interrupt enabled on printer acknowledge) 5 x 6 x 7 x We want to check if the printer is On-line. To do that we read port 0379h. In Pascal is : FUNCTION PRN_OnLine:BOOLEAN; BEGIN IF ((port[$379] and 16)==16) THEN PRN_OnLine:=TRUE ELSE PRN_OnLine:=FALSE; END; Note that this function will return FALSE also if the printer is not connected. (select=0) In the same way you can make functions for paper out and check if the printer buffer is full. (busy) Hope this will help. Fredrik Kvamme. Division of Computer Systems and Telematics Norwegian Institute of Technology, NTH Tronheim Norway