[comp.sys.ibm.pc.misc] Printing with Pascal 5.5

@crdgw1.ge.com:erwvegm@cs.vu.nl (exos:) (03/06/91)

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' ?

Please send your answer to : erwvegm@cs.vu.nl

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++ Erwin van Egmond UUCP: ...!mcsun!cs.vu.nl!erwvegm|           ++
++								++
++ Space is big.  You just won't believe how vastly, hugely,    ++
++ mindbogglingly big it is.  I mean, you may think it's a long ++ 
++ way down the road to the drug store, but that's		++
++ just peanuts to space.					++
++		-- "The Hitchhiker's Guide to the Galaxy"	++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

fredrik@solan.unit.no (Fredrik Knoph Kvamme) (03/15/91)

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

jerry@gumby.Altos.COM (Jerry Gardner) (04/16/91)

In article <9419@trev.dsir.govt.nz> SRPDSDJ@trev.dsir.govt.nz (Sid) writes:

}> FUNCTION PRN_OnLine:BOOLEAN;
}> 
}> BEGIN
}> IF ((port[$379] and 16)==16) THEN PRN_OnLine:=TRUE
}                         ^
}the problem is my compiler does not like the == above, what am I doing 
}wrong? Also forgive my stupidity/ignorance but where does the 16 come from?  

Your problem is simple; "==" is the C equality operator, not Pascal.  The
Pascal equality operator is "=".


-- 
Jerry Gardner, NJ6A					Altos Computer Systems
UUCP: {sun|pyramid|sco|amdahl|uunet}!altos!jerry	2641 Orchard Parkway
Internet: jerry@altos.com				San Jose, CA  95134
Help stamp out vi in our lifetime.                      (408) 432-6200