home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
t
/
tcsel003.zip
/
PRINTER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-10-16
|
2KB
|
63 lines
unit Myprint;
{$D-,I-,S-}
interface
uses dos;
var
Prt : array[1..2] of text;
Lst : text absolute Prt;
function PrinterStatus(p: byte): byte;
function PrinterReady(var b : byte; p: byte): boolean;
implementation
procedure RawMode(var L); { make sure that device is in raw mode }
var
regs : registers;
begin
with regs do begin
bx := TextRec(L).Handle; { place the file handle in bx }
ax := $4400; { setup for function $44 sub-function 0 }
MSDos(regs); { execute dos function }
dl := dl or $20; { bit 5 = raw mode }
dh := 0; { set dh to zero }
ax := $4401; { setup for function $44 sub-function 1 }
MSDos(regs) { execute dos function }
end; { with }
end; { RawMode }
function PrinterStatus(p: byte): byte;
{ Returns the printer status. LPT1=p=1, LPT2=p=2 }
var regs : registers; { from the dos unit }
begin
with regs do begin
dx := p - 1; { The printer number }
ax := $0200; { The function code for service wanted }
intr($17,regs); { $17= ROM bios int to return printer status}
PrinterStatus := ah;{ Bit 0 set = timed out }
end; { 1 = unused }
end; { 2 = unused }
{ 3 = I/O error }
{ 4 = printer selected }
{ 5 = out of paper }
{ 6 = acknowledge }
{ 7 = printer not busy }
function PrinterReady(var b : byte; p: byte): boolean;
begin
b := PrinterStatus(p);
PrinterReady := (b = $90) { This may vary between printers }
end;
begin
assign(Prt[1],'LPT1');
rewrite(Prt[1]);
RawMode(Prt[1]);
assign(Prt[2],'LPT2');
rewrite(Prt[2]);
RawMode(Prt[2]);
end.