1. [GEN] Printer detection
I have a need to send file data to the printer, after determining whether a
printer is present and accessible. The
following code happily executes, even when there is no printer attached to the
puter.
-- <Begin Code >
procedure onClick_ButtonPrint()
close( Patterns )
-- open PATTERNS.TXT as input, open printer as output, print file,
close printer, close PATTERNS.TXT
Patterns=open( "PATTERNS.TXT","rb" )
if Patterns = -1 then
result = message_box( "Open Patterns.txt FAILED in
OnClick_ButtonPrint. Aborting. ","ERROR!", {} ) abort(1)
end if
Printer = open("PRN","w") -- valid handle is assigned, even tho no
printer
if Printer = -1 then
result = message_box( "Unable to find a printer; skipping.",
"ERROR!", {} )
else
while 1 do
line=gets(Patterns)
if atom(line) then
close( Patterns )
close(Printer )
exit
end if
line=line[1..80]&"\n"
puts(Printer,line)
end while
end if
end procedure
-- <End Code >
Can any one tell me how to detect the presence or (lack) of a printer? I checked
the doco and the archives and user
contributions. All I could find (doing a search for printer) was Barend
Maaskant's Print Utility, which I can't get to
work for missing lib's (which also can't be found anywhere).
Any suggestions will be much appreciated.
Thanks.
2. Re: [GEN] Printer detection
Dos interrupt #17 will give you printer status, as shown in the example
below (for printer 0):
-- start code
include machine.e
sequence regs
integer status
regs = repeat(0, 10)
regs[REG_AX] = #0200
regs = dos_interrupt(#17, regs)
status = regs[REG_AX]/#100
if and_bits(status, 8) then
puts(1, "printer i/o error\n")
end if
if and_bits(status, 16) then
puts(1, "printer selected\n")
end if
-- end code
- Colin Taylor
----- Original Message -----
From: Jim <futures8 at EARTHLINK.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Saturday, January 20, 2001 3:39 PM
Subject: [GEN] Printer detection
> I have a need to send file data to the printer, after determining whether
a printer is present and accessible. The
> following code happily executes, even when there is no printer attached to
the puter.