home *** CD-ROM | disk | FTP | other *** search
- Unit Print;
- { Author : Michael Warot
- Date : May,1988
- Last : November, 1988
- Purpose : Provide an easy to use print unit that WORKS!
- Notes : Turbo 5.0 (Should work with 4)
- Uses PopUpConfirm - Replace with your own boolean function
- Uses Unit Timer2 - Included for completeness
- }
- Interface
-
- Uses
- Crt,Dos,Misc;
-
- Procedure AssignLpt(var F : Text);
-
- Implementation
- {***************** This is hidden from the users code *******************}
- {$F+} { If not already on }
-
- Uses
- Timer2,
- EditPage; { PopUpConfirm }
- Var
- AbortPrint : Boolean;
-
- Procedure LptInit(Var F : TextRec);
- Begin
- With F do
- begin
- BufPos := 0;
- end;
- End;
-
- Function LptInChar: Char;
- Begin
- LptInChar := #0;
- End;
-
- Procedure LptOutChar(Ch : Char);
- Var
- R : Registers;
- T : Longint;
- Begin
- If Not AbortPrint then
- begin
- StartTime(T);
- Repeat
- R.AH := 0;
- R.AL := Byte(Ch);
- R.DX := 0;
- Intr($17,R);
- If DT(T) > 90 then
- If PopUpConfirm('TIMEOUT, ABORT PRINT') then
- AbortPrint := True;
- Until (R.AH = $10) OR (AbortPrint);
- end;
- End; { LptOutChar }
-
- Function LptInReady: Boolean;
- Begin
- LptInReady := True;
- End;
-
- Function LptInput(var F: TextRec): Integer;
- begin
- LptInput:=0;
- end;
-
- Function LptOutPut(var F: TextRec): Integer;
- var
- P: Word;
- begin
- with F do
- begin
- P:=0;
- while P<BufPos do
- begin
- LptOutChar(BufPtr^[P]); Inc(P);
- end;
- BufPos:=0;
- end;
- LptOutput := 0;
- end;
-
- Function LptIgnore(var F: TextRec): Integer;
- begin
- LptIgnore:=0;
- end;
-
- Function LptClose(Var F: TextRec): Integer;
- Begin
- LptClose := 0;
- End;
-
- Function LptOpen(var F: TextRec): Integer;
- begin
- with F do
- begin
- LptInit(F);
- if Mode=fmInput then
- begin
- InOutFunc:=@LptInput;
- FlushFunc:=@LptIgnore;
- end else
- begin
- Mode:=fmOutput;
- InOutFunc:=@LptOutput;
- FlushFunc:=@LptOutput;
- end;
- CloseFunc:=@LptClose;
- end;
- AbortPrint := False;
- LptOpen:=0;
- end;
-
- procedure AssignLpt;
- begin
- with TextRec(F) do
- begin
- Handle:=$FFFF;
- Mode:=fmClosed;
- BufSize:=SizeOf(Buffer);
- BufPos := $00;
- BufPtr:=@Buffer;
- OpenFunc:=@LptOpen;
- Name[0]:=#0;
- end;
- end;
-
- begin
- end.