home *** CD-ROM | disk | FTP | other *** search
- {---------------------------------------------------------------------------}
- { Print, Println, PrintTest and PrintInit Routines }
- { Written By: }
- { Kenneth Krakow }
- { 114 N. Orchard St. }
- { Madison, WI 53715 }
- { 257-1354 }
- { }
- { The following Printer routines must have the following Type declarations }
- { as well as ST255=string[255]. The type checking option 'V' must be }
- { disabled by $V-. }
- { Print: Function which prints string to printer and returns Error Code.}
- { Println: Function which Prints string to printer with Line Feed and }
- { Return, and returns Error Code. }
- { PrintTest: Function which returns Status of Printer. }
- { PrintInit: Initializes printer and sets to Top of Form. }
- { NOTE: 'PORT' in the parameter of the following procedures refers to }
- { Printer Port Number 0, 1, or 2. }
- {---------------------------------------------------------------------------}
-
- {$V-}
- Type
- PrintError = (OK,PaperOut,IOerr);
- Result = Record
- AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer;
- End;
-
- {---------------------------------------------------------------------------}
- { PrintInt }
- { This procedure sets the printer to it's default settings. }
- {---------------------------------------------------------------------------}
-
- Procedure PrintInit(Port:integer);
-
- Var
- Reg: result;
-
- Begin
- reg.Ax:=256;
- Reg.DX:=Port;
- Intr($17,Reg);
- End;
-
- {---------------------------------------------------------------------------}
- { PrintTest }
- { This Function will Test the printer and return PaperOut if the Paper is }
- { out, or IOerr if some other printing error occured. If everthing is OK }
- { OK will be returned. }
- {---------------------------------------------------------------------------}
-
- Function PrintTest(Port:Integer):PrintError;
-
- Var
- Reg: result;
- Test: Byte;
-
- Begin
- Reg.AX:=2 Shl 8;
- Reg.DX:=Port;
- Intr($17,Reg);
- Test:=HI(Reg.AX);
- PrintTest:=Ok;
- If (Test and 8)=8 then PrintTest:=IOerr;
- If (Test and 32)=32 then PrintTest:=PaperOut;
- End;
-
- {---------------------------------------------------------------------------}
- { Print }
- { This function will test the printer and print PrintString if Test returns }
- { OK. Otherwise it will not print Printstring and just return the value of }
- { TEST. }
- {---------------------------------------------------------------------------}
-
- Function Print(Port:integer;Printstring:St255):PrintError;
-
- Var
- Reg: result;
- Test: PrintError;
- S,L:integer;
-
- Begin
- L:=Length(PrintString);
- S:=1;
- Reg.DX:=Port;
- Test:=PrintTest(Port);
-
- While (S<=L) AND (TEST=OK) do Begin
- Reg.AX:=ORD(PrintString[S]);
- Intr($17,Reg);
- S:=S+1;
- End;
- Print:=Test;
- End;
-
- {---------------------------------------------------------------------------}
- { Println }
- { This function will test the printer and print PrintString followed by a }
- { return and a Line Feed if Test returns OK. Otherwise it will not print }
- { Printstring and just return the value of TEST. }
- {---------------------------------------------------------------------------}
-
- Function PrintLn(Port:integer;Printstring:St255):PrintError;
-
- Var
- Reg: result;
- Test: PrintError;
- S,L:integer;
-
- Begin
- L:=Length(PrintString);
- S:=1;
- Reg.DX:=Port;
- Test:=PrintTest(Port);
-
- While (S<=L) AND (TEST=OK) do Begin
- Reg.AX:=ORD(PrintString[S]);
- Intr($17,Reg);
- S:=S+1;
- End;
- If Test=OK then begin
- Reg.AX:=13;
- Intr($17,Reg);
- Reg.AX:=10;
- Intr($17,Reg);
- End;
- End;
-