Article View: comp.os.msdos.programmer
Article #170Re: LPT timeout trapping?
From: Lee Hollingworth
Date: Sat, 01 Aug 1992 13:33
Date: Sat, 01 Aug 1992 13:33
61 lines
1854 bytes
1854 bytes
dahls@fhydra.dnet.unit.no (Joern Yngve Dahl-Stamnes) writes:
>Hello.
>I'm doing a fprintf (stdprn,...) in program. The only problem is that if the
>printer isn't on-line, I get this annoying message on the screen. The message
>is annoying because my program is a screen oriented program.
>Is there any way to trap this fault so that my program can display the message
>(or my own message) on the screen when this happen? I've been looking in the
>FAQ, but could not find it.
You might like to try using the Int17h functions to get the printer status
and write to the printer...
#include <stdio.h>
#include <dos.h>
#define OUT_OF_PAPER 0x20
#define IO_ERROR 0x08
void print(char *str)
{
union REGS regs;
regs.x.dx = 0;
while (*str) {
regs.h.ah = 0x00;
regs.h.al = *str;
int86(0x17, ®s, ®s);
++str;
}
}
int prn_ok(void)
{
union REGS regs;
regs.h.ah = 2;
regs.x.dx = 0;
int86(0x17, ®s, ®s);
if (regs.h.ah & OUT_OF_PAPER) {
puts("Printer is out of paper");
return 0;
}
if (regs.h.ah & IO_ERROR) {
puts("Printer IO error");
return 0;
}
return 1;
}
void main(void)
{
if (prn_ok()) {
print("Printer is on-line and okay!");
}
}
Lee Hollingworth
s1110238@giaeb.cc.monash.edu.au
Technical Details
Message-ID:
<s1110238.712676031@giaeb>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!giaeb!s1110238References:
<0095E572.CDB34C80@FHYDRA.FYSEL.UNIT.NO>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!giaeb!s1110238 From: s1110238@giaeb.cc.monash.edu.au (Lee Hollingworth) Subject: Re: LPT timeout trapping? Message-ID: <s1110238.712676031@giaeb> Sender: news@monu6.cc.monash.edu.au (Usenet system) Organization: Monash University, Melb., Australia. References: <0095E572.CDB34C80@FHYDRA.FYSEL.UNIT.NO> Date: Sat, 1 Aug 1992 13:33:51 GMT Lines: 61