[GEN] Printer detection

new topic     » topic index » view thread      » older message » newer message

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.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu