home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 16 / 16.iso / w / w048 / 2.ddi / MSSRC.ARC / MSPRINT.INC < prev    next >
Encoding:
Text File  |  1987-12-21  |  21.7 KB  |  706 lines

  1. {                            MSPRINT.INC
  2.                                MS 4.0
  3.                 Copyright (c) 1985, 87 by Borland International, Inc.         }
  4.  
  5.   procedure EdPrintExit;
  6.     {-Quit printing}
  7.  
  8.   begin                      {EdPrintExit}
  9.     if not(Printing) then
  10.       Exit;
  11.     Printing := False;
  12.     with PrintJob do begin
  13.       {Close up input and output files}
  14.       Close(PrintFile);
  15.       if EdINT24Result <> 0 then
  16.         EdErrormsg(45);
  17.       if ToFile then
  18.         Close(OutFile);
  19.       if EdINT24Result <> 0 then
  20.         EdErrormsg(46);
  21.       UpdateScreen := True;
  22.     end;
  23.   end;                       {EdPrintExit}
  24.  
  25.   function EdFixPrintError(E : PrintErrorType) : Boolean;
  26.     {-Attempt to fix or ignore common printer errors}
  27.   var
  28.     Ch : Char;
  29.  
  30.   begin                      {EdFixPrintError}
  31.     {Temporarily turn off printing to stop background processing}
  32.     Printing := False;
  33.     {Display a message and get a key stroke}
  34.     EdDisplayPromptWindow(
  35.                           EdGetMessage(363+Ord(E))+EdGetMessage(370), 12, [#13, #27], Ch, ErrorBox);
  36.     {Return true if user fixed error condition, or tried to}
  37.     EdFixPrintError := not(Abortcmd) and (Ch = #13);
  38.     {Turn printing back on, at least momentarily}
  39.     Printing := True;
  40.   end;                       {EdFixPrintError}
  41.  
  42.   function EdPrintStackOverflow(Cur, Len : Integer) : Boolean;
  43.     {-Check whether print stack is about to overflow}
  44.   var
  45.     Junk : Boolean;
  46.  
  47.   begin                      {EdPrintStackOverflow}
  48.     if Cur+Len > PrintStackSize then begin
  49.       {Buffer overflow, not fixable, just notify and stop printing}
  50.       Junk := EdFixPrintError(PrtCmdTooLong);
  51.       EdPrintExit;
  52.       EdPrintStackOverflow := True;
  53.     end else
  54.       EdPrintStackOverflow := False;
  55.   end;                       {EdPrintStackOverflow}
  56.  
  57.   procedure EdPushPrintChars(var S; Slen : Integer);
  58.     {-Push some characters onto the print stack, s is a string or another stack}
  59.   var
  60.     P : PrintStack absolute S;
  61.     Cpos : Integer;
  62.  
  63.   begin                      {EdPushPrintChars}
  64.     with PrintJob do begin
  65.       if EdPrintStackOverflow(StackIndex, Slen) then
  66.         Exit;
  67.       {Push printer command on stack in reverse order}
  68.       Cpos := Slen;
  69.       while Cpos > 0 do begin
  70.         Inc(StackIndex);
  71.         Stack[StackIndex] := P[Cpos];
  72.         Dec(Cpos);
  73.       end;
  74.     end;
  75.   end;                       {EdPushPrintChars}
  76.  
  77.   procedure EdPushPrintString(S : PrintCommand);
  78.     {-Push a command string onto print stack}
  79.  
  80.   begin                      {EdPushPrintString}
  81.     EdPushPrintChars(S, Length(S));
  82.   end;                       {EdPushPrintString}
  83.  
  84.   procedure EdPrintNext(PrintChars : Integer);
  85.     {-Background process to print the next PrintChars characters of print job}
  86.   var
  87.     Pch : Char;
  88.     I : Integer;
  89.  
  90.     function EdPrintTranslate(Ch : Char; var Fstate : PrintFontState) : String255;
  91.       {-Interpret printer controls embedded in print file, returning a control string}
  92.     var
  93.       C : PrintCommandtype;
  94.  
  95.     begin                    {EdPrintTranslate}
  96.       C := PrintMap[Ch];
  97.       {Return the printer control string}
  98.       EdPrintTranslate := PrintDef.Commands[C] [Fstate[C]];
  99.       {Toggle the font state}
  100.       Fstate[C] := not(Fstate[C]);
  101.     end;                     {EdPrintTranslate}
  102.  
  103.     function EdBuildHeaderFooter(HeFo : Boolean) : String255;
  104.       {-Return a formatted header or footer string}
  105.  
  106.       function EdPutPageNumber(Col, Num : Integer) : String255;
  107.         {-Return a string with the page number properly positioned}
  108.       var
  109.         S, O : String255;
  110.  
  111.       begin                  {EdPutPageNumber}
  112.         Str(Num, S);
  113.         if Col+Length(S) > 255 then
  114.           {String too long, ignore it}
  115.           EdPutPageNumber := ''
  116.         else begin
  117.           O[0] := Chr(Pred(Col+Length(S)));
  118.           FillChar(O[1], Pred(Col), Blank);
  119.           Move(S[1], O[Col], Length(S));
  120.           EdPutPageNumber := O;
  121.         end;
  122.       end;                   {EdPutPageNumber}
  123.  
  124.       function EdInterpret(S : String255; PageNum : Integer) : String255;
  125.         {-Interpret a header or footer string, returning a formatted one}
  126.       var
  127.         Ipos : Integer;
  128.         O, T : String255;
  129.         Ch : Char;
  130.         Fstate : PrintFontState;
  131.  
  132.       begin                  {EdInterpret}
  133.  
  134.         {Header and footer have an independent format state}
  135.         FillChar(Fstate, SizeOf(Fstate), False);
  136.  
  137.         EdClearString(O);
  138.         Ipos := 1;
  139.  
  140.         {Scan the input string}
  141.         while Ipos <= Length(S) do begin
  142.           Ch := S[Ipos];
  143.  
  144.           if PrintMap[Ch] <> PrtNone then
  145.  
  146.             {Add appropriate control commands to output}
  147.             O := O+EdPrintTranslate(Ch, Fstate)
  148.  
  149.           else
  150.             case Ch of
  151.  
  152.               '#' :          {Insert Page Number}
  153.                 begin
  154.                   Str(PageNum, T);
  155.                   O := O+T;
  156.                 end;
  157.  
  158.               '\' :          {Take next character literally}
  159.                 begin
  160.                   Inc(Ipos);
  161.                   if Ipos <= Length(S) then
  162.                     O := O+S[Ipos];
  163.                 end;
  164.  
  165.               ^K :           {Ignore any following spaces on even pages}
  166.                 if not(Odd(PageNum)) then begin
  167.                   repeat
  168.                     Inc(Ipos);
  169.                   until (Ipos > Length(S)) or (S[Ipos] <> Blank);
  170.                   Dec(Ipos);
  171.                 end;
  172.  
  173.             else
  174.               {Normal text}
  175.               O := O+Ch;
  176.             end;
  177.  
  178.           Inc(Ipos);
  179.         end;
  180.  
  181.         EdInterpret := O;
  182.  
  183.       end;                   {EdInterpret}
  184.  
  185.     begin                    {EdBuildHeaderFooter}
  186.       with PrintJob do begin
  187.         if HeFo then
  188.           {Header}
  189.           EdBuildHeaderFooter := EdInterpret(Header, PageNum)
  190.         else begin
  191.           {Footer}
  192.           if EdStringEmpty(Footer) and ShowPageNum then
  193.             {Display the page number in standard column}
  194.             EdBuildHeaderFooter := EdPutPageNumber(Pagecol, PageNum)
  195.           else
  196.             EdBuildHeaderFooter := EdInterpret(Footer, PageNum);
  197.         end;
  198.       end;
  199.     end;                     {EdBuildHeaderFooter}
  200.  
  201.     procedure EdPageBoundary(StartEnd : Boolean);
  202.       {-Push text at start or end of page}
  203.     var
  204.       L, Next, Maxl, Specl : Integer;
  205.       P : PrintStack;
  206.       UseHeFo : Boolean;
  207.  
  208.       function EdResetPrintAttributes(TurnOn : Boolean) : String255;
  209.         {-Return a string to turn all current print attributes on or off}
  210.       var
  211.         S : String255;
  212.         C : PrintCommandtype;
  213.  
  214.       begin                  {EdResetPrintAttributes}
  215.         EdClearString(S);
  216.         with PrintJob do
  217.           for C := PrtBold to PrtAlt2 do
  218.             if FontState[C] then
  219.               S := S+PrintDef.Commands[C] [not(TurnOn)];
  220.         EdResetPrintAttributes := S;
  221.       end;                   {EdResetPrintAttributes}
  222.  
  223.       procedure EdAppendPrintText(L : String255; var P : PrintStack; var Next : Integer);
  224.         {-Append string l to buffer t, checking for overflow and updating next}
  225.  
  226.       begin                  {EdAppendPrintText}
  227.         if EdPrintStackOverflow(Next, Length(L)) then
  228.           Exit;
  229.         Move(L[1], P[Next], Length(L));
  230.         Next := Next+Length(L);
  231.       end;                   {EdAppendPrintText}
  232.  
  233.     begin                    {EdPageBoundary}
  234.       with PrintJob do begin
  235.  
  236.         Next := 1;
  237.  
  238.         {Initialize for header or footer}
  239.         if StartEnd then begin
  240.           {Start of page}
  241.           PushStart := False;
  242.           if Line < 1 then
  243.             Line := 1;
  244.           if Tmargin = 0 then
  245.             {Don't paginate if top margin is set to zero}
  246.             Exit;
  247.           Maxl := Tmargin;
  248.           Specl := Succ(HTMargin);
  249.           UseHeFo := (HTMargin < Tmargin);
  250.         end else begin
  251.           {End of page}
  252.           PushEnd := False;
  253.           if Bmargin = 0 then
  254.             {Don't paginate if bottom margin is set to zero}
  255.             Exit;
  256.           Maxl := PageLen;
  257.           Specl := PageLen-FBMargin;
  258.           UseHeFo := (FBMargin < Bmargin);
  259.         end;
  260.  
  261.         {Don't insert headers and footers if not formatting}
  262.         if not(Format) then
  263.           Exit;
  264.  
  265.         {Turn off current print attributes}
  266.         EdAppendPrintText(EdResetPrintAttributes(False), P, Next);
  267.  
  268.         {Add blank lines and header or footer}
  269.         for L := Line to Maxl do begin
  270.           {Get out in case of stack overflow}
  271.           if not(Printing) then
  272.             Exit;
  273.           if UseHeFo and (L = Specl) then
  274.             {Insert header or footer}
  275.             EdAppendPrintText(EdBuildHeaderFooter(StartEnd), P, Next);
  276.           if L < Maxl then
  277.             {Insert end of line}
  278.             EdAppendPrintText(EolMark, P, Next);
  279.         end;
  280.  
  281.         {Turn current print attributes back on}
  282.         EdAppendPrintText(EdResetPrintAttributes(True), P, Next);
  283.  
  284.         {Insert end of line}
  285.         if PrintDef.FormfeedMode and not(StartEnd) then
  286.           {Terminate with formfeed at end of page}
  287.           EdAppendPrintText(EopMark, P, Next)
  288.         else
  289.           EdAppendPrintText(EolMark, P, Next);
  290.  
  291.         {Push characters onto print stack to be printed when time permits}
  292.         EdPushPrintChars(P, Pred(Next));
  293.  
  294.       end;
  295.     end;                     {EdPageBoundary}
  296.  
  297.     procedure EdStartNewPage;
  298.       {-Update flags and counters for a new page}
  299.     var
  300.       Ch : Char;
  301.  
  302.     begin                    {EdStartNewPage}
  303.       with PrintJob do begin
  304.         Inc(PageNum);
  305.         Line := 1;
  306.         if Format and not(ToFile) and PrintDef.PaperPause then begin
  307.           {Prompt for paper change}
  308.           EdDisplayPromptWindow(EdGetMessage(345), 12, [#13], Ch, NormalBox);
  309.           if Abortcmd then
  310.             EdPrintExit;
  311.         end;
  312.         PushEnd := True;
  313.         PushStart := True;
  314.       end;
  315.     end;                     {EdStartNewPage}
  316.  
  317.     function EdPrintError(ToFile : Boolean; ErrorNum : Integer) : Boolean;
  318.       {-Return true if error occurred during character print}
  319.     var
  320.       E : Byte;
  321.       P : PrintErrorType;
  322.  
  323.     begin                    {EdPrintError}
  324.       EdPrintError := False;
  325.       if ToFile then begin
  326.         if ErrorNum = 0 then
  327.           Exit;
  328.         {Error writing file}
  329.         EdPrintError := True;
  330.         P := PrtFileWrite;
  331.       end else begin
  332.         {ErrorNum is a BIOS printer status byte}
  333.         E := ErrorNum and $28;
  334.         if E = 0 then
  335.           Exit;
  336.         EdPrintError := True;
  337.         case E of
  338.           $20 : P := PrtNoResponse;
  339.           $08 : P := PrtOffLine;
  340.           $28 : P := PrtOutPaper;
  341.         else
  342.           P := PrtUnknown;
  343.         end;
  344.       end;
  345.       {Attempt to fix error}
  346.       if not(EdFixPrintError(P)) then
  347.         EdPrintExit;
  348.     end;                     {EdPrintError}
  349.  
  350.     function EdGetPrintChar(EvaluateToggles : Boolean) : Char;
  351.       {-Return next char to print}
  352.     var
  353.       GotChar : Boolean;
  354.       Ch : Char;
  355.  
  356.       procedure EdCheckNextChar(EvaluateToggles : Boolean; var Ch : Char; var GotChar : Boolean);
  357.         {-Return the next character in the print buffer}
  358.  
  359.         function EdGetStackedChar : Char;
  360.           {-Return the next stacked char to be printed}
  361.  
  362.         begin                {EdGetStackedChar}
  363.           with PrintJob do begin
  364.             EdGetStackedChar := Stack[StackIndex];
  365.             Dec(StackIndex);
  366.           end;
  367.         end;                 {EdGetStackedChar}
  368.  
  369.       begin                  {EdCheckNextChar}
  370.  
  371.         GotChar := False;
  372.  
  373.         with PrintJob do begin
  374.  
  375.           if StackIndex > 0 then begin
  376.             {Finish sending stacked characters before reading more input}
  377.             Ch := EdGetStackedChar;
  378.             GotChar := True;
  379.             if StackIndex = 0 then
  380.               {Printer is now caught up with pending control commands}
  381.               FontState := PendingFontState;
  382.             Exit;
  383.           end;
  384.  
  385.           if BufferPtr = 0 then begin
  386.             {No more input available, and print stack empty}
  387.             EdPrintExit;
  388.             Exit;
  389.           end;
  390.  
  391.           if BufferPtr > BufferChars then begin
  392.             {Buffer used up, refill it}
  393.             if EoF(PrintFile) then begin
  394.               {No more input, signal end of job}
  395.               BufferChars := 1;
  396.               Buffer[1] := ^Z;
  397.             end else begin
  398.               EdBlockRead(PrintFile, Buffer, PrintBufferSize, BufferChars);
  399.               if Goterror then
  400.                 if not(EdFixPrintError(PrtFileRead)) then begin
  401.                   EdPrintExit;
  402.                   Exit;
  403.                 end;
  404.             end;
  405.             BufferPtr := 1;
  406.             Exit;
  407.           end;
  408.  
  409.           {Get next character from buffer}
  410.           Ch := Buffer[BufferPtr];
  411.  
  412.           if Ch = ^Z then begin
  413.             {Last input character}
  414.             BufferPtr := 0;
  415.             {Put ^Z on print stack}
  416.             EdPushPrintString(Ch);
  417.             if Format then
  418.               {Put printer reset string on print stack}
  419.               EdPushPrintString(PrintDef.Commands[PrtInit] [True]);
  420.             {Put last footer on print stack}
  421.             EdPageBoundary(False);
  422.             {Indicate that last page is in progress}
  423.             LastPage := True;
  424.             Exit;
  425.           end;
  426.  
  427.           Inc(BufferPtr);
  428.  
  429.           {Translate ^O (non-breaking space) to space}
  430.           if Format then
  431.             if Ch = ^O then
  432.               Ch := Blank;
  433.  
  434.           {Evaluate printer toggle commands}
  435.           if Format and EvaluateToggles and (PrintMap[Ch] <> PrtNone) then
  436.             {Push appropriate print commands onto print stack}
  437.             EdPushPrintString(EdPrintTranslate(Ch, PendingFontState))
  438.           else
  439.             {Pass Ch through unchanged}
  440.             GotChar := True;
  441.  
  442.         end;
  443.       end;                   {EdCheckNextChar}
  444.  
  445.     begin                    {EdGetPrintChar}
  446.       repeat
  447.         EdCheckNextChar(EvaluateToggles, Ch, GotChar);
  448.         if not(Printing) then
  449.           {Printing terminated}
  450.           Exit;
  451.       until GotChar;
  452.       EdGetPrintChar := Ch;
  453.     end;                     {EdGetPrintChar}
  454.  
  455.     procedure EdEvaluateFormatCommands;
  456.       {-Evaluate formatting commands for printing}
  457.     var
  458.       Pch : Char;
  459.       I : Integer;
  460.       Com : string[2];
  461.       Arg : String255;
  462.       Len : Byte absolute Arg;
  463.  
  464.       procedure EdInsertPageBreak;
  465.         {-Add header and blank lines to fill out a page}
  466.       var
  467.         I, Tline : Integer;
  468.  
  469.       begin                  {EdInsertPageBreak}
  470.         with PrintJob do begin
  471.           if PushStart then
  472.             Tline := Succ(Tmargin)
  473.           else
  474.             Tline := Line;
  475.           for I := Tline to (PageLen-Bmargin) do begin
  476.             {Insert blank lines}
  477.             EdPushPrintString(EolMark);
  478.             if not(Printing) then
  479.               {Stack overflow occurred}
  480.               Exit;
  481.           end;
  482.           {Put the header on the stack}
  483.           if PushStart then
  484.             EdPageBoundary(True);
  485.         end;
  486.       end;                   {EdInsertPageBreak}
  487.  
  488.     begin                    {EdEvaluateFormatCommands}
  489.  
  490.       {Read the line into a string}
  491.       Len := 0;
  492.       repeat
  493.         {Don't evaluate print toggles while building string}
  494.         Pch := EdGetPrintChar(False);
  495.         if not(Printing) then
  496.           Exit;
  497.         Inc(Len);
  498.         Arg[Len] := Pch;
  499.       until (Len >= Length(EolMark)) and
  500.       (Copy(Arg, Succ(Len-Length(EolMark)), Length(EolMark)) = EolMark);
  501.  
  502.       {Remove the EolMark}
  503.       Len := Len-Length(EolMark);
  504.  
  505.       if Len >= 2 then begin
  506.  
  507.         {Separate the command and the argument}
  508.         Com[0] := #2;
  509.         for I := 1 to 2 do begin
  510.           Com[I] := Upcase(Arg[1]);
  511.           Delete(Arg, 1, 1);
  512.         end;
  513.  
  514.         with PrintJob do begin
  515.           {Evaluate the format commands and change print parameters}
  516.           case Pos(Com, FormatCommands) of
  517.             1 : EdInsertPageBreak; {PA}
  518.             4 : begin        {CP}
  519.                   I := 0;
  520.                   EdArg2Integer(Arg, 0, PageLen, I);
  521.                   if (PageLen-Tmargin-Bmargin-Line) < I then
  522.                     EdInsertPageBreak;
  523.                 end;
  524.             7 : EdArg2Integer(Arg, 1, MaxPage, PageNum); {PN}
  525.             10 : EdArg2Integer(Arg, Succ(Tmargin+Bmargin), (PrintStackSize-MaxHeaderChars) shr 1, PageLen); {PL}
  526.             13 : EdArg2Integer(Arg, 0, Pred(PageLen-Bmargin), Tmargin); {MT}
  527.             16 : EdArg2Integer(Arg, 0, Pred(PageLen-Tmargin), Bmargin); {MB}
  528.             19 : EdArg2Integer(Arg, 0, MaxHeaderChars shr 1, Loffset); {PO}
  529.             22 : EdArg2Integer(Arg, 0, Pred(PageLen-Bmargin), HTMargin); {HM}
  530.             25 : EdArg2Integer(Arg, 0, Pred(PageLen-Tmargin), FBMargin); {FM}
  531.             28 : ShowPageNum := False; {OP}
  532.             31 : ShowPageNum := True; {PG}
  533.             34 : Header := Arg; {HE}
  534.             37 : Footer := Arg; {FO}
  535.             40 : EdArg2Integer(Arg, 0, MaxHeaderChars shr 1, Pagecol); {PC}
  536.           end;
  537.         end;
  538.  
  539.       end;
  540.     end;                     {EdEvaluateFormatCommands}
  541.  
  542.     procedure EdPushLeadingSpace(Loffset : Integer);
  543.       {-Push spaces for page offset}
  544.     var
  545.       P : PrintStack;
  546.  
  547.     begin                    {EdPushLeadingSpace}
  548.       FillChar(P[1], Loffset, Blank);
  549.       EdPushPrintChars(P, Loffset);
  550.     end;                     {EdPushLeadingSpace}
  551.  
  552.     function EdPrinterBusy(Printer : Integer) : Boolean;
  553.       {-Check for printer busy}
  554.     var
  555.       regs : registers;
  556.  
  557.     begin                    {EdPrinterBusy}
  558.       with regs do begin
  559.         Ah := 2;
  560.         Dx := Printer;
  561.         intr($17, regs);
  562.         if (Ah and $80) = 0 then
  563.           EdPrinterBusy := EdPrintError(False, Ah)
  564.         else
  565.           EdPrinterBusy := False;
  566.       end;
  567.     end;                     {EdPrinterBusy}
  568.  
  569.     procedure EdPrintChar(Pch : Char);
  570.       {-Print character to selected device}
  571.     var
  572.       Printed : Boolean;
  573.       regs : registers;
  574.  
  575.     begin                    {EdPrintChar}
  576.       with PrintJob, regs do begin
  577.         if ToFile then
  578.           repeat
  579.             {Write character to file}
  580.             Write(OutFile, Pch);
  581.             Printed := not(EdPrintError(True, EdINT24Result));
  582.           until Printed or not(Printing)
  583.         else if (Pch <> ^Z) then
  584.           repeat
  585.             {Write character to printer}
  586.             Dx := Printer;
  587.             ax := Ord(Pch);
  588.             intr($17, regs);
  589.             Printed := not(EdPrintError(False, Ah));
  590.           until Printed or not(Printing);
  591.       end;
  592.     end;                     {EdPrintChar}
  593.  
  594.     procedure EdUpdatePosition(Pch : Char);
  595.       {-Keep track of printer page position}
  596.  
  597.     begin                    {EdUpdatePosition}
  598.       with PrintJob do begin
  599.  
  600.         if (Pch = #12) then begin
  601.  
  602.           {Form feed}
  603.           EdStartNewPage;
  604.           Line := 0;
  605.           NewLine := not(LastPage);
  606.  
  607.         end else if (Pch = #13) then
  608.  
  609.           {Carriage return}
  610.           Column := 1
  611.  
  612.         else if (Pch = #10) then begin
  613.  
  614.           {Line feed}
  615.           Inc(Line);
  616.           NewLine := True;
  617.           if (Line > PageLen) then begin
  618.             {Time for new page}
  619.             if not(LastPage) then
  620.               EdStartNewPage;
  621.           end else if Line = Succ(PageLen-Bmargin) then begin
  622.             {Time for footer}
  623.             if PushEnd then
  624.               {Finish this page}
  625.               EdPageBoundary(False);
  626.           end;
  627.  
  628.         end else
  629.           {Normal printing character}
  630.           Inc(Column);
  631.       end;
  632.     end;                     {EdUpdatePosition}
  633.  
  634.   begin                      {EdPrintNext}
  635.  
  636.     with PrintJob do
  637.       for I := 1 to PrintChars do begin
  638.  
  639.         {Get out if keystrokes waiting}
  640.         if EdKeyInterrupt then
  641.           Exit;
  642.  
  643.         {Check for printer busy}
  644.         if not(ToFile) then
  645.           if EdPrinterBusy(Printer) then
  646.             Exit;
  647.  
  648.         {Get next character to print}
  649.         Pch := EdGetPrintChar(True);
  650.         if not(Printing) then
  651.           Exit;
  652.  
  653.         if PrinterInit then begin
  654.  
  655.           {Write printer initialization codes before anything else}
  656.           EdPrintChar(Pch);
  657.  
  658.           if StackIndex = 0 then
  659.             PrinterInit := False;
  660.  
  661.         end else begin
  662.  
  663.           {Check for formatting commands}
  664.           if Format then
  665.             if (Pch = FormatChar) and NewLine and (Column = 1) then begin
  666.               {Evaluate formatting command}
  667.               EdEvaluateFormatCommands;
  668.               Exit;
  669.             end;
  670.  
  671.           {Handle left offset and page boundaries}
  672.           if NewLine then begin
  673.             {Put character back on stack}
  674.             EdPushPrintString(Pch);
  675.  
  676.             if PushStart then
  677.               {Put leading lines and header on stack}
  678.               EdPageBoundary(True);
  679.             if NewLine then begin
  680.               {Put leading blanks on stack}
  681.               if Format and (Loffset > 0) then
  682.                 EdPushLeadingSpace(Loffset);
  683.               NewLine := False;
  684.             end;
  685.  
  686.             {Get next character to print}
  687.             Pch := EdGetPrintChar(True);
  688.             if not(Printing) then
  689.               Exit;
  690.           end;
  691.  
  692.           {Print if on selected page}
  693.           if not(Format) or
  694.           ((PageNum >= StartPage) and (PageNum <= StopPage)) then begin
  695.             EdPrintChar(Pch);
  696.             if not(Printing) then
  697.               Exit;
  698.           end;
  699.  
  700.           {Keep track of position}
  701.           EdUpdatePosition(Pch);
  702.         end;
  703.  
  704.       end;
  705.   end;                       {EdPrintNext}
  706.