dara@cs.mcgill.ca (Dara UNG) (06/22/91)
Hi there, I have problem in finding printer status (ON/OFF). Could someone out there suggest a solution ? The system that my application running is XT, TP 5.5 I've tried the following code suggested by Tom Swan, "Mastering Turbo Pascal 5.5", but the output from PrintStatus always is 255 regrardless of the ON/OFF state of printer! var PrintStatus : byte; begin PrintStatus := Port [ $03BD]; writeln (PrintStatus); end; I guess the adddress of printer status '03BD' is incorrect! Thanks in advance, Dara Ung. dara@cs.mcgill.ca
dm2368@eecs1.eecs.usma.edu (Fichten Mark CPT) (06/23/91)
> From: Dara UNG <dara@cs.mcgill.ca> > > 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.
ts@uwasa.fi (Timo Salmi) (06/24/91)
In article <1991Jun22.163830.21689@cs.mcgill.ca> dara@cs.mcgill.ca (Dara UNG) writes: : > I have problem in finding printer status (ON/OFF). Could someone > out there suggest a solution ? > The system that my application running is XT, TP 5.5 : Have you tried the ubiquitous routines in /pc/ts/tspa23##.arc (## = 40,50,55,60) available from our site. ................................................................... Prof. Timo Salmi Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37 School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun
phys169@csc.canterbury.ac.nz (06/24/91)
In article <1991Jun22.163830.21689@cs.mcgill.ca>, dara@cs.mcgill.ca (Dara UNG) writes: > I've tried the following code suggested by Tom Swan, "Mastering Turbo > Pascal 5.5", but the output from PrintStatus always is 255 > regardless of the ON/OFF state of printer! > Try... var PrintStatus : byte; LptPortAddr : array[1..4] of word absolute 0:$408; begin PrintStatus := Port [LprPortAddr[1]]; writeln (PrintStatus); end; The idea is to find the actual port addresses from the table BIOS creates during power-on self-testing. Otherwise teh port address for LPT1 depends on such factors as the type of vidoe display you have. An even better idea is to use interrupt $17 (with AH=2) or possibly MsDos call $44, to allow for such things as printer redirection. So you could declare... const LPT1 = 0; LPT2 = 1; LPT3 = 2; LPT4 = 3; function PrinterStatus(WhichPrinter : word) : byte; inline($B4/$02/ { mov ah,2 } $5A/ { pop dx } $CD/$17/ { int 17h } $8A/$C4); { mov al,ah } Hope this helps, Mark Aitchison, Physics, University of Canterbury, New Zealand. [insert favourite quote from BlackAdder/Goodies/Spike Milligoon/Penfold here]
Russell_Mennie@resbbs.UUCP (Russell Mennie) (06/26/91)
Ok.. this way should work.. although, you'll have to know how to use
Interupts to do it... but...
Your going to be accessing Interupt 17h ... I'll give you the basics..
in pascal:
Uses
Dos;
var
R :Registers
Status :Byte;
Begin
R.Ah:= $02; { Specifies Function call }
R.Dx:= 0; { Printer port 0-3 }
Intr($17,R); { Perform Function call }
Status:= R.Ah; { Status Returned in AH }
{ -- Bits of variable Status are now:
0 = time out
1 = unused
2 = unused
3 = I/O error
4 = selected
5 = out of paper
6 = acknowledge
7 = not busy
-- So you can tell if the printer is on
or not by this.. This is simply the
-Get Printer Status- function call..
}