Board index » delphi » Printer Drivers

Printer Drivers

Finally replaced an old dot matrix printer with an HP Deskjet 712C.  The
manual says I can print from a DOS program running within Windows 95 if
the DOS program has a driver for the Deskjet 660C or 550C.  Surely
someone has written a Turbo Pascal 6.0 printer module (or many) to cope
with modern printers.  Timo's FAQ didn't seem to help.
 

Re:Printer Drivers


In article <3686AC48.9BECD...@worldnet.attdotnet>,
Robert Olson  <olson....@worldnet.attDOTnet> wrote:

Quote
>Finally replaced an old dot matrix printer with an HP Deskjet 712C.  The
>manual says I can print from a DOS program running within Windows 95 if
>the DOS program has a driver for the Deskjet 660C or 550C.  Surely
>someone has written a Turbo Pascal 6.0 printer module (or many) to cope
>with modern printers.  Timo's FAQ didn't seem to help.

It all depends on what you want to print. Here is an unit that has some
basic commands. If you need to pass a parameter, use for example
Write(lst,wp(cpi,10));

unit pclconst;

interface

const

  resetprt=#27'E';
  selftest=#27'z';

  Landscape=#27'&l1O';
  Portrait=#27'&l0O';

  {attributes }

  Underline=#27'&d3D';
  Doubleunderline=#27'&d4D';
  FixedUnderline=#27'&d1D';
  FixedDoubleunderline=#27'&d2D';
  UnderlineOff=#27'&d@';
  Bold=#27'(s3B';
  Italics=#27'(s1S';
  BoldOff=#27'(s0B';
  ItalicsOff=#27'(s0S';
  BIoff=#27'(s0s0B';

  Fixed=#27's0P';
  proportional=#27's1P';
  UniDirectional=#27'&k0W';
  Bidirectional=#27'&k1W';

  Cpi=#27'(s#H';
  Height=#27's#V';

  Draft=#27'(s1Q'#27'*r1Q';   { first for text second for graphics }
  LQ=#27'(s2Q'#27'*r2Q';

  { Character sets }

  PC8=#27'(10U';    { Standard PC char set }
  PC850=#27'(12U';  { PC multinational }
  Roman8=#27'(8U';
  Latin1=#27'(0N';

  lpi=#27'&l#D';               { Send this group in the order presented }
  PaperDefault=#27'&l0A';      { That is first lpi, then paper, then }
  PaperLetter=#27'&l1A';       { margins etc. }
  PaperLegal=#27'&l2A';
  PaperA4=#27'&l3A';           { To get different spacing within page }
  Pagelen=#27'&l#P';           { Use VMI or MoveDown }
  PerfSkipOff=#27'&l1L';
  PerfSkipOn=#27'&l0L';
  LeftMargin=#27'&a#L';
  RightMargin=#27'&a#M';
  ClearMargins=#27'9';
  Topmargin=#27'l#E';
  TextLength=#27'&l#F';

  VMI=#27'&l#C';               { Vertical motion index #/48" }
  HMI=#27'&k#H';               { Horizontal motion index #/120" }

  { Moving the cursor }

  MovetoRow=#27'&a#R';
  MoveToCol=#27'&a#C';
  MoveDownRows=#27'&a+#R';
  MoveRightCols=#27'&a+#C';
  MoveUpRows=#27'&a-#R';     { use with caution. }
  MoveLeftCols=#27'&a-#C';

  MoveToDotY=#27'*p#Y';
  MoveToDotX=#27'*p#X';
  MoveDownDots=#27'*p+#Y';
  MoveRightDots=#27'*p+#X';
  MoveUpDots=#27'*p-#Y';           { use with caution }
  MoveLeftDots=#27'*p-#X';

  MoveToDecipointY=#27'&a#V';
  MoveToDecipointX=#27'&a#H';
  MoveDownDecipoints=#27'&a+#V';
  MoveRightDecipoints=#27'&a+#H';
  MoveUpDecipoints=#27'&a-#V';     { use with caution }
  MoveLeftDecipoints=#27'&a-#H';

  { Graphics }

  GraphicsResol=#27'*t#R';         { 75, 100, 150, 300, on some models 600 }
  GraphWidth=#27'*r#S';            { pixels }
  CompactOff=#27'*b0M';
  CompactMode1=#27'*b1M';
  CompactMode2=#27'*b2M';
  StartGraphics=#27'*r1A';         { starts at current position }
  TransferRow=#27'*b#W';
  CloseGraphics=#27'*rB';

  DisplayFunctions=#27'Y';         { Good for debugging }
  DisplayFunctionsOff=#27'Z';

  Transparent=#27'*p#X';           { Print # characters as text }
  Transp1=#27'*p1X';               { print a single control character }
  Wrap=#27'&s0C';                  { in general avoid automatic wrap and do }
  WrapOff=#27'&s1C';               { it manually between words }

  { Line termination }

  LTnorm=#27'&k0G';
  LTUnix=#27'&k2G';                 { CR->CR, LF -> CRLF, FF->CRFF }
                                    { works with both Unix and DOS eol }
  LTCR=#27'&1G';                    { CR->CRLF, LF -> LF, FF-FF }
  LTCRorLF=#27'&3G';                { CR->CRLF, LF -> CRLF, FF-CRFF }

  Eject=#27'&l0H';                  { Does not eject an empty page like FF }
                                    { does }
  { some "macros" }

  HalfHeight=#27's6V';
  FullHeight=#27's12V';
  Cpi10=#27'(s10H';
  Cpi12=#27'(s12H'#27'&k10H'; { Force the font to 12CPI with HMI }
  Cpi17=#27'(s16.67H';
  Cpi20=#27'(s20H';
  Cpi5=#27'(s5H';
  Cpi6=#27'(s6H'#27'&k20H';

type sst=string[25];

Function wp(template:sst; value:word): sst;
Function fxp(template:sst; value:longint): sst; {2 decimals}
Function rp(template:sst; value:real): sst;

implementation

Procedure InsSt(var template:sst;{$ifdef ver70}const{$endif} s:sst);
var i:integer;
begin
  i:=pos('#',template);
  if i>0 then begin
     delete(template,i,1);
     insert(s,template,i);
  End;
end;

Function wp(template:sst; value:word): sst;
var s:string[5];
begin
  str(value,s);
  InsSt(template,s);
  wp:=template;
End;

Function fxp(template:sst; value:longint): sst;
var s:string[12];
    f:string[2];
begin
  str(value div 100,s);
  str(value mod 100:2,f);
  byte(f[1]):=byte(f[1]) or $30;  {convert possible leading space into '0'}
  s:=s+'.'+f;
  while s[length(s)]='0' do dec(byte(s[0]));
  if s[length(s)]='.' then dec(byte(s[0]));
  InsSt(template,s);
  fxp:=template;
End;

Function rp(template:sst; value:real): sst;
var s:string[10];
begin
  str(value:1:3,s);
  while s[length(s)]='0' do dec(byte(s[0]));
  if s[length(s)]='.' then dec(byte(s[0]));
  InsSt(template,s);
  rp:=template;
End;

end.

Other Threads