Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ISPRINTER() & XP 1

Status
Not open for further replies.

Tombrx

Programmer
Dec 16, 2005
3
US
Using XP, this function always returns .T. so it can't detect printer off line or out of paper.

Does anyone have a UDF that will detect these situations?

Thanks ahead
 
This is a rather 'How different is Windows from DOS' type of question.
- On DOS you always should handle any printer 'out of order' situation. If you didn't an application would halt until the situation is taken care of.
- On Windows, printers are fed by a 'spooler' system, Windows catches any app's output, puts it in a queue, and stuffs it into the printer, if an when it's ready for it.
No _need_ for an app to check if the printer is ready.

OTOH, if you need to be sure that some information is actualy printed and has come out of that printer, before the app can continue, as is most usual the case when this question pops up, then you need to get access to the printer info in some way. Time to get your hands dirty on Windows compatible (32 bit) programmin'!

The easies way to be able to get this info is to recompile your code with (x)Harbour, available from either (slow developing but stable), (commercial supoorted version of the .org with added options and tools) or (open source). (x)Harbour is a Clipper 5.2/5.3 compatible compiler that's available for several platforms, like Windows, Unix, Linux, Mac OS-X and OS/2.
Go to any of the before mentioned websites and get the info/stuff you need. xharbour.com is the easiest to get started, xharbour.org is the cheapest way to get things rolling, and is also very well supported with a very active community on the news server nntp://news.xharbour.org

HTH
TonHu
 
TonHu:
Thanks, I'll check it out.
Tombrx
 
Even in xp, you can check for printer, but only if it is local printer, connected with parallel cable to computer. If you are using s87, there are some helpful functions:
- Printready, Printstat and Isbit
I use following code:

FUNCTION Prt_Chk
IMEPRO='PRT_CHK' && not relevant
if type("dosprt")="U" && not relevant
dosprt=1
endif
NAPREJ=.F.
IF .NOT. Printready(dosprt) && Printer is not ready
status = Printstat(dosprt) && Get status
DO CASE
CASE Isbit(status,1) && 1st bit on ?
@8,41 SAY "NOT busy ... "
CASE Isbit(status,2) && 2nd bit on ?
@8,41 SAY "Acknowledged ... "
CASE Isbit(status,3) && 3rd bit on ?
@8,41 SAY "End of paper error "
CASE Isbit(status,4) && 4th bit on ?
@8,41 SAY "On line, NOT ready "
CASE Isbit(status,5) && 5th bit on ?
@8,41 SAY "Powered off ... "
CASE Isbit(status,8) && 8h bit on ?
@8,41 SAY "Time out error ... "
ENDCASE
ELSE
NAPREJ=.T.
@8,41 SAY "On line & busy ... "
ENDIF
INKEY(.2)
IF LASTKEY()=27
NAPREJ=.T.
ENDIF
RETURN NAPREJ
&& end of code

All three functions are part of NT1.LIB - nantucket tools for s87 clipper.

If you are printing to a network printer like:
net use lpt2: \\servername\printername
then it is impossible to check out the status of pins of parallel port and it is not necessary either, because all printout will go to spooler of the computer that is serving the printer and when printer become online, it will print all jobs.

Hope I helped.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top