home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB16.ZIP / PRINT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-02-06  |  4.5 KB  |  127 lines

  1. {---------------------------------------------------------------------------}
  2. {              Print, Println, PrintTest and PrintInit Routines             }
  3. {                           Written By:                                     }
  4. {                          Kenneth Krakow                                   }
  5. {                        114 N. Orchard St.                                 }
  6. {                        Madison, WI 53715                                  }
  7. {                            257-1354                                       }
  8. {                                                                           }
  9. { The following Printer routines must have the following Type declarations  }
  10. { as well as ST255=string[255].  The type checking option 'V' must be       }
  11. { disabled by $V-.                                                          }
  12. { Print:     Function which prints string to printer and returns Error Code.}
  13. { Println:   Function which Prints string to printer with Line Feed and     }
  14. {            Return, and returns Error Code.                                }
  15. { PrintTest: Function which returns Status of Printer.                      }
  16. { PrintInit: Initializes printer and sets to Top of Form.                   }
  17. {  NOTE: 'PORT' in the parameter of the following procedures refers to      }
  18. {        Printer Port Number 0, 1, or 2.                                    }
  19. {---------------------------------------------------------------------------}
  20.  
  21. {$V-}
  22. Type
  23.  PrintError = (OK,PaperOut,IOerr);
  24.  Result     = Record
  25.                AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer;
  26.               End;
  27.  
  28. {---------------------------------------------------------------------------}
  29. {                            PrintInt                                       }
  30. { This procedure sets the printer to it's default settings.                 }
  31. {---------------------------------------------------------------------------}
  32.  
  33. Procedure PrintInit(Port:integer);
  34.  
  35. Var
  36.  Reg: result;
  37.  
  38. Begin
  39.  reg.Ax:=256;
  40.  Reg.DX:=Port;
  41.  Intr($17,Reg);
  42. End;
  43.  
  44. {---------------------------------------------------------------------------}
  45. {                               PrintTest                                   }
  46. { This Function will Test the printer and return PaperOut if the Paper is   }
  47. { out, or IOerr if some other printing error occured.  If everthing is OK   }
  48. { OK will be returned.                                                      }
  49. {---------------------------------------------------------------------------}
  50.  
  51. Function PrintTest(Port:Integer):PrintError;
  52.  
  53. Var
  54.  Reg: result;
  55.  Test: Byte;
  56.  
  57. Begin
  58.  Reg.AX:=2 Shl 8;
  59.  Reg.DX:=Port;
  60.  Intr($17,Reg);
  61.  Test:=HI(Reg.AX);
  62.  PrintTest:=Ok;
  63.  If (Test and 8)=8 then PrintTest:=IOerr;
  64.  If (Test and 32)=32 then PrintTest:=PaperOut;
  65. End;
  66.  
  67. {---------------------------------------------------------------------------}
  68. {                                 Print                                     }
  69. { This function will test the printer and print PrintString if Test returns }
  70. { OK.  Otherwise it will not print Printstring and just return the value of }
  71. { TEST.                                                                     }
  72. {---------------------------------------------------------------------------}
  73.  
  74. Function Print(Port:integer;Printstring:St255):PrintError;
  75.  
  76. Var
  77.  Reg: result;
  78.  Test: PrintError;
  79.  S,L:integer;
  80.  
  81. Begin
  82.  L:=Length(PrintString);
  83.  S:=1;
  84.  Reg.DX:=Port;
  85.  Test:=PrintTest(Port);
  86.  
  87.  While (S<=L) AND (TEST=OK) do Begin
  88.   Reg.AX:=ORD(PrintString[S]);
  89.   Intr($17,Reg);
  90.   S:=S+1;
  91.  End;
  92. Print:=Test;
  93. End;
  94.  
  95. {---------------------------------------------------------------------------}
  96. {                                 Println                                   }
  97. { This function will test the printer and print PrintString followed by a   }
  98. { return and a Line Feed if Test returns OK.  Otherwise it will not print   }
  99. { Printstring and just return the value of TEST.                            }
  100. {---------------------------------------------------------------------------}
  101.  
  102. Function PrintLn(Port:integer;Printstring:St255):PrintError;
  103.  
  104. Var
  105.  Reg: result;
  106.  Test: PrintError;
  107.  S,L:integer;
  108.  
  109. Begin
  110.  L:=Length(PrintString);
  111.  S:=1;
  112.  Reg.DX:=Port;
  113.  Test:=PrintTest(Port);
  114.  
  115.  While (S<=L) AND (TEST=OK) do Begin
  116.   Reg.AX:=ORD(PrintString[S]);
  117.   Intr($17,Reg);
  118.   S:=S+1;
  119.  End;
  120.  If Test=OK then begin
  121.   Reg.AX:=13;
  122.   Intr($17,Reg);
  123.   Reg.AX:=10;
  124.   Intr($17,Reg);
  125.  End;
  126. End;
  127.