Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!hsdndev!cmcl2!adm!news From: dm2368@eecs1.eecs.usma.edu (Fichten Mark CPT) Newsgroups: comp.lang.pascal Subject: Re: Help in Printer Status! Message-ID: <27276@adm.brl.mil> Date: 23 Jun 91 00:34:10 GMT Sender: news@adm.brl.mil Lines: 116 > From: Dara UNG > > Hi there, > > I have problem in finding printer status (ON/OFF). Could someone > out there suggest a solution ? [some deleted] Try the following unit. You will have to make some minor adjustments. For example: INI.PrinterType is an array of 2 strings. They can contain NONE, ASCII, or PS. INI.DefaultPrinter is an integer equal to 1 or 2. Hope this helps you out. ____________________________________________________________________________ CPT Mark Fichten | INTERNET: fichten@eecs1.eecs.usma.edu | Captain U.S. Army | @trotter.edu:dm2368@eecs1.eecs.usma.edu | Work: (914) 938-5580 | USENET: rutgers.edu!trotter!eecs1!dm2368 | | harvard.edu!trotter!eecs1!dm2368 | ____________________________________________________________________________ {$F+,O+,X+,D-} unit prntstat; interface function DefaultPrinterIsOk(var ErrorCode : byte) : boolean; function PrinterErrorString (Error : integer) : string; procedure ResetPrinter; implementation uses Crt, Dos; function DefaultPrinterIsOk(var ErrorCode : byte) : boolean; var Regs : registers; begin if INI.PrinterType[INI.DefaultPrinter] = 'NONE' then begin ErrorCode := 5; DefaultPrinterIsOK := false; Exit; end; with regs do begin Ah := 2; case INI.PrinterPort[INI.DefaultPrinter][4] of {LPT}'1' : Dx := 0; {LPT}'2' : Dx := 1; end; intr($17,regs); if (Ah and $B8) = $90 then ErrorCode := 0 { All's Well } else if (Ah and $20) = $20 then ErrorCode := 1 { Turned Off/No paper } else If (Ah and $10) = $00 then ErrorCode := 2 { Off line } else If (Ah and $80) = $00 then ErrorCode := 3 { Busy } else {If (Ah and $08) = $08 then} ErrorCode := 4; { Undetermined error } end; DefaultPrinterIsOK := ErrorCode = 0; end; function PrinterErrorString (Error : integer) : string; begin case Error of 0 : PrinterErrorString := 'Ready'; 1 : PrinterErrorString := 'Turned Off or Out of Paper'; 2 : PrinterErrorString := 'Not Properly Selected/On Line'; 3 : PrinterErrorString := 'Busy'; 4 : PrinterErrorString := 'Undetermined Error Condition'; 5 : PrinterErrorString := 'No Default Printer Selected'; end; end; procedure ResetPrinter; var Regs : registers; begin if INI.PrinterType[INI.DefaultPrinter] = 'NONE' then Exit; with Regs do begin Regs.Ah := 1; case INI.PrinterPort[INI.DefaultPrinter][4] of {LPT}'1' : Dx := 0; {LPT}'2' : Dx := 1; end; intr($17,regs); end; end; end.