Board index » delphi » Printer Problem

Printer Problem

Hi all,

I repeat my earlier question making it hereby more precise: does anyone
know a REALLY RELIABLE method that detects if a printer is online? If
you have a look at the 3 routines documented in the FAQs on Garbo, none
of them ALWAYS detects e.g. that no printer is connected to the computer
(at least that was the case on my machine). But there should be a way
(how does Windows do it)?

Any comments?

Regards,
Thomas.
--
Thomas Blesgen
bles...@mis.mpg.de

 

Re:Printer Problem


JRS:  In article <3C5A92DD.90E64...@mis.mpg.de>, seen in
news:comp.lang.pascal.borland, Thomas Blesgen <bles...@mis.mpg.de> wrote
at Fri, 1 Feb 2002 14:06:37 :-

Quote
>I repeat my earlier question making it hereby more precise: does anyone
>know a REALLY RELIABLE method that detects if a printer is online? If
>you have a look at the 3 routines documented in the FAQs on Garbo, none
>of them ALWAYS detects e.g. that no printer is connected to the computer
>(at least that was the case on my machine). But there should be a way
>(how does Windows do it)?

A printer can be connected, two-wire, to a serial port - an ASR33 or
emulator, for example.  There being no means of signal flow out of the
printer into the computer, your wish cannot always be accomplished.

Printers can give various signals back to the computer, and, for those,
Windows can tell.  Windows, at least up to Windows 3, is merely a DOS
application; anything it can do, you can do in Pascal .. if you know
how.

You will need to determine what signals are returned to the computer by
the printer in question.

Most printer interfaces have some sort of flow control; you could
possibly use this, by seeing if the data is sent from the computer at
the proper speed.  Too fast implies no printer signal to say "slower";
not at all implies no printer signal to say "more, please".  But
buffered printers will be awkward.

Note that it may be easier to send something to the printer and tell
whether it was received than to predict whether future data would be
received.

For a local printer, the ultimate test is to display "Is the printer
ready/working" and to get the user to reply; at least, it shifts the
blame.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Re:Printer Problem


Thomas Blesgen wrote in <3C5A92DD.90E64...@mis.mpg.de>

[deleted'

Quote
> Any comments?

  Did you try to use direct access to LPT-port?

--
   Varyonov Konstantin       varkos^mail.ru      http://ghsrl.newmail.ru

Re:Printer Problem


Quote
"Konstantin V. Varyonov" wrote:
>  Did you try to use direct access to LPT-port?
> --
>    Varyonov Konstantin       varkos^mail.ru      http://ghsrl.newmail.ru

Hi all,

one of the 3 printer detection routines on Garbo reads the port. But, as
I can assure you, this is not 100% reliable,  not even in the case of a
local printer on LPT1.

I would like to thank Dr. Stockton for his advice. After having tried now
many different approaches, my final conclusion is that THE solution to this
problem does not exist and the guys of IBM had a bad day when they designed
the printer control.

Kind regards,
--
Thomas Blesgen.

Quote

Re:Printer Problem


Quote
Thomas Blesgen wrote:

> I repeat my earlier question making it hereby more precise: does anyone
> know a REALLY RELIABLE method that detects if a printer is online? If
> you have a look at the 3 routines documented in the FAQs on Garbo, none
> of them ALWAYS detects e.g. that no printer is connected to the computer
> (at least that was the case on my machine). But there should be a way
> (how does Windows do it)?

What is exactly you want to check for - any examples?
Isn't it sufficient to use the BIOS to deliver data to the printer, and
return an error to your program if the printer for some reason is not
ready to accept data ?
You mentioned local printer on LPT1 - is that *the* scenario ?

/klaus

Re:Printer Problem


Hi,
I use the following functions. It works for me.
May be, you can use it too.

Wim
========================
function CheckPrinter : byte;
var
  Regs : Registers;
begin
  Regs.DX:=0;
  Regs.AX:=$0200;
  intr(23,Dos.Registers(Regs));
  CheckPrinter:=hi(Regs.AX)
end;

function printer_is_off:boolean;
begin
if (CheckPrinter=144) or (checkprinter=16) then printer_is_off:=FALSE else
printer_is_off:=TRUE
end;
==========================

"Thomas Blesgen" <bles...@mis.mpg.de> schreef in bericht
news:3C5A92DD.90E64BE7@mis.mpg.de...

Quote
> Hi all,

> I repeat my earlier question making it hereby more precise: does anyone
> know a REALLY RELIABLE method that detects if a printer is online? If
> you have a look at the 3 routines documented in the FAQs on Garbo, none
> of them ALWAYS detects e.g. that no printer is connected to the computer
> (at least that was the case on my machine). But there should be a way
> (how does Windows do it)?

> Any comments?

> Regards,
> Thomas.
> --
> Thomas Blesgen
> bles...@mis.mpg.de

Re:Printer Problem


I have been running TP7 Dos programs on a Win98 network and checking whether
or not a printer is on line before beginning a report is critical.  As I
recall, this will also work with printers that are on the network. (They
must show up as LPT1, 2 or 3 on the user's system.)

I use Port Array to examine the next byte above the Port's Base Address. For
example, LPT1 is usually at $378 (Hex 378 or 888 in decimal), so for LPT1,
look at $379 and use SHR 4 to get the upper four bits. (Ex. 208 shr 4 = 13,
240 shr 4 = 15.)

The following values are the only ones I have bothered to check:
  4 = Off Line
  6 = Paper Out
  7 > 9 = Printer Off
  13 = On Line
  15 = No Printer

This method has also been adapted to a Windows Program (using Visual Basic)
and it allows me to access printers directly which is much faster than going
through Windows.

Windows can scramble the actual Port Addresses, especially if an LPT Card
has been added, so you might have to check the addresses.

I hope this helps you out.
-----

Quote
Thomas Blesgen wrote:
> Hi all,

> I repeat my earlier question making it hereby more precise: does anyone
> know a REALLY RELIABLE method that detects if a printer is online? If
> you have a look at the 3 routines documented in the FAQs on Garbo, none
> of them ALWAYS detects e.g. that no printer is connected to the computer
> (at least that was the case on my machine). But there should be a way
> (how does Windows do it)?

> Any comments?

> Regards,
> Thomas.
> --
> Thomas Blesgen
> bles...@mis.mpg.de

--
Val Mehling
va...@earthlink.net

Web Pages
http://home.earthlink.net/~valjm/

XRL (Extreme Racing League) Pics
http://odin.prohosting.com/~valjm

http://odin.prohosting.com/valmeh/

Other Threads