home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP4PRINT.ZIP / PRINTER.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1988-01-24  |  1.8 KB  |  68 lines

  1. {$I-,R-}
  2.  
  3. unit Printer;
  4.  
  5. { A replacement unit for the standard Turbo 4 PRINTER unit.
  6.   This unit solves problems with outputing printer control strings
  7.   and graphics data through the LST file.
  8.  
  9.   Version 1.0 -  1/24/1988 - First general release
  10.  
  11.   Scott Bussinger
  12.   Professional Practice Systems
  13.   110 South 131st Street
  14.   Tacoma, WA  98444
  15.   (206)531-8944
  16.   Compuserve 72247,2671 }
  17.  
  18.  
  19. interface
  20.  
  21. uses Dos;
  22.  
  23. var Lst: text;
  24.  
  25.  
  26. implementation
  27.  
  28. var ExitSave: pointer;
  29.     SaveMode: boolean;
  30.  
  31. function SetDeviceMode(Handle: word;SetRawMode: boolean): boolean;
  32.   { Return the current value of the device raw/cooked mode and set to new mode }
  33.   var Regs: Registers;
  34.   begin
  35.   with Regs do
  36.     begin
  37.     AX := $4400;                                 { Get the current device status }
  38.     BX := Handle;
  39.     MsDos(Regs);
  40.     SetDeviceMode := odd(DX shr 5);              { Test the current value of RAW bit }
  41.     AX := $4401;                                 { Set the new device status }
  42.     BX := Handle;
  43.     DX := DX and $00DF;                          { Clear the RAW bit }
  44.     if SetRawMode then
  45.       inc(DX,32);                                { Turn the RAW bit on }
  46.     MsDos(Regs)
  47.     end
  48.   end;
  49.  
  50. {$F+}
  51. procedure ExitHandler;
  52.   { Restore the original PRN device mode and close file }
  53.   var DontCare: boolean;
  54.   begin
  55.   ExitProc := ExitSave;                          { Chain to other exit procedures }
  56.   DontCare := SetDeviceMode(TextRec(Lst).Handle,SaveMode); { Restore the original device mode }
  57.   close(Lst)
  58.   end;
  59. {$F-}
  60.  
  61. begin
  62. assign(Lst,'PRN');                               { Open the printer device }
  63. rewrite(Lst);
  64. SaveMode := SetDeviceMode(TextRec(Lst).Handle,true); { Set to RAW (binary) mode }
  65. ExitSave := ExitProc;
  66. ExitProc := @ExitHandler
  67. end.
  68.