home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / GRAPHX.ZIP / GRAPHX.FIX
Encoding:
Text File  |  1985-12-28  |  19.7 KB  |  601 lines

  1. PRODUCT : TURBO GRAPHIX TOOLBOX
  2. VERSION : X.XX
  3.      OS : PC-DOS
  4.  
  5. -----------------------------------------------------------------
  6.   TITLE : TURBO GRAPHIX TOOLBOX PROBLEM FIXES
  7. -----------------------------------------------------------------
  8.  
  9. This  is  an explanation of all known changes and fixes to  TURBO
  10. GRAPHIX  TOOLBOX since it was originally introduced.  The  TURBO
  11. GRAPHIX TOOLBOX is provided in source code form,  so you can make
  12. these  changes  directly  to the source code.  The  reason  these
  13. changes  must  be  made is that the calls  to  SelectWindow  from
  14. procedures  DrawAxis,  DrawPolygon,  and  DrawHistogram  set  the
  15. variables X1Glb,  Y1Glb,  X2Glb, and Y2Glb to zero. These are the
  16. global  discriptors  for the axis margins in the current  window,
  17. but  they  are destroyed upon  leaving  procedure  DrawAxis.  The
  18. changes  described  in the following pages modify the  procedures
  19. AXIS.HGH,  POLYGON.HGH, and HISTOGRM.HGH so that the axis margins
  20. maintain  the correct values.  After the modifications have  been
  21. made, a typical calling sequence for plotting several curves on a
  22. common axis frame would be:
  23.  
  24.  
  25.             DrawAxis(...);         { Define the axis frame. }
  26.             DrawPolygon(...);      { Plot first curve.      }
  27.             ResetAxis;             { Set AxisGlb to true.   }
  28.             DrawPolygon(...);      { Plot second curve.     }
  29.             ResetAxis;             { Set AxisGlb to true.   }
  30.             DrawHistogram(...);    { Plot third curve.      }
  31.  
  32. This is a rather lengthy file.  All the modifications you may need to make to
  33. your version of Graphix Toolbox are marked here with a string of at least five
  34. asterisks (*).  Use Turbo Pascal's editor's Ctrl-Q Ctrl-F command to locate all
  35. occurrences of the string, "*****", and you will find all the modifications
  36. that have been made to this set of routines.
  37.  
  38. If you make the changes described, you should change the header
  39. of all the modules that end in .HGH to read:
  40.  
  41.        "TURBO GRAPHIX version 1.05A"
  42.  
  43. You   should  change  the  module  version  number  in  AXIS.HGH, 
  44. POLYGON.HGH,and HISTOGRM.HGH to read:
  45.  
  46.        "Module version 1.05A"
  47.  
  48. Note: You should also delete the variable declaration:
  49.  
  50.                      Font : IBMFont;
  51.  
  52. from  the file DUMMY.INC .
  53.  
  54.  
  55.  
  56.                          AXIS.HGH
  57.  
  58.    (***********************************************************)
  59.    (*                TURBO GRAPHIX version 1.03A              *)
  60.    (*                                                         *)
  61.    (*                   Axis drawing module                   *)
  62.    (*                  Module version  1.03A                  *)
  63.    (*                                                         *)
  64.    (*                  Copyright (C) 1985 by                  *)
  65.    (*                  BORLAND International                  *)
  66.    (***********************************************************)
  67. ****************** ( CHANGE 1.03A TO 1.05A ) ******************
  68.  
  69. procedure DrawAxis(XDens,YDens,XLeft,YTop,XRight,YBottom,XAxis,
  70.                    YAxis:integer;
  71.                    Arrows:boolean);
  72.  var LineStyleLoc,xk0,yk0,xk1,yk1,xk2,yk2,NDiff:integer;
  73.      x2,y2,MaxExponentX,MaxExponentY,i,ys,xs,Delta,NPoints:integer;
  74.      Difference,Number,s,Fract:real;
  75.      X1RefLoc,X2RefLoc,Y1RefLoc,Y2RefLoc,X1RefLoc2,X2RefLoc2,
  76.      Y1RefLoc2,Y2RefLoc2:integer;
  77.      ClippingLoc,DirectModeLoc,HeaderLoc:boolean;
  78.  
  79.   function StringNumber(X1:real;
  80.                         MaxExponent:integer):wrkstring;
  81.     var y:wrkstring;
  82.  
  83.     begin
  84.       str(X1*exp(-MaxExponent*ln(10.0)):5:2,y);
  85.  
  86.       StringNumber:=y;
  87.     end;
  88.  
  89.   function GetExponent(X1:real):integer;
  90.     begin
  91.       GetExponent:=0;
  92.       if X1<>0.0 then
  93.         if abs(X1)>=1.0 then GetExponent:=trunc(ln(abs(X1))/ln(10.0))
  94.         else GetExponent:=-trunc(abs(ln(abs(X1)))/ln(10.0)+1.0);
  95.     end;
  96.  
  97.   procedure DrawNum(x1,y1,MaxExponent:integer;
  98.                     Number:real);
  99.     var i:integer;
  100.         StrNumber:wrkstring;
  101.  
  102.     begin
  103.       StrNumber:=StringNumber(Number,MaxExponent);
  104.       y1:=y1-3;
  105.       for i:=1 to 5 do DrawAscii(x1,y1,1,ord(StrNumber[i]));
  106.     end;
  107.  
  108.   function Balance:integer;
  109.     begin
  110.       Balance:=0;
  111.       s:=s+Fract;
  112.       if s>=0 then
  113.        begin
  114.         s:=s-1.0;
  115.         Balance:=1;
  116.        end;
  117.     end;
  118.  
  119.   procedure DrawExponent(x1,y1,MaxExponent:integer);
  120.     var i:integer;
  121.         StrNumber:wrkstring;
  122.     begin
  123.       y1:=y1-3;
  124.       x1:=x1+1;
  125.       DrawAscii(x1,y1,1,49);
  126.       DrawAscii(x1,y1,1,48);
  127.       str(MaxExponent:3,StrNumber);
  128.       y1:=y1-3;
  129.       x1:=x1-7;
  130.       for i:=1 to 3 do DrawAscii(x1,y1,1,ord(StrNumber[i]));
  131.     end;
  132.  
  133.   begin { DrawAxis }
  134.     LineStyleLoc:=LinestyleGlb;
  135.     SetLineStyle(0);
  136.  
  137.     AxisGlb:=true;   <----------{***** DELETE THIS LINE. *****}
  138.  
  139.     DirectModeLoc:=DirectModeGlb;
  140.     DirectModeGlb:=true;
  141.     with window[WindowNdxGlb] do
  142.      begin
  143.       X1RefLoc:=x1;
  144.       X2RefLoc:=x2;
  145.       Y1RefLoc:=y1;
  146.       Y2RefLoc:=y2;
  147.  
  148.                    <---|
  149.       X1Glb:=XLeft;    |
  150.       X2Glb:=XRight;   |--------{***** DELETE THIS BLOCK. *****}
  151.       Y1Glb:=YTop;     |
  152.       Y2Glb:=YBottom;  |
  153.                    <---|
  154.  
  155. {***** CHANGE THE FOLLOWING CALL TO ReDefineWindow TO READ :  *****}
  156. { ReDefineWindow(WindowNdxGlb,x1+XLeft,y1+YTop,x2-XRight,y2-YBottom); }
  157.  
  158.  ReDefineWindow(WindowNdxGlb,x1+X1Glb,y1+Y1Glb,x2-X2Glb,y2-Y2Glb);
  159.  
  160.       SelectWindow(WindowNdxGlb);
  161.      end;
  162.     if (XDens<0) xor (YDens<0) then
  163.      begin
  164.       HeaderLoc:=HeaderGlb;
  165.       HeaderGlb:=False;
  166.       DrawBorder;
  167.       HeaderGlb:=HeaderLoc;
  168.      end;
  169.     XDens:=abs(XDens);
  170.     YDens:=abs(YDens);
  171.     if XDens>9 then XDens:=0;
  172.     if YDens>9 then YDens:=0;
  173.     xk0:=(X1RefGlb+4) shl 3;
  174.     yk0:=Y2RefGlb-14;
  175.     yk1:=Y1RefGlb+6;
  176.     xk1:=xk0;
  177.     yk2:=yk0;
  178.     xk2:=(X2RefGlb-2) shl 3+7;
  179.     if (XAxis>=0) or (YAxis>=0) then
  180.      begin
  181.       ClippingLoc:=ClippingGlb;
  182.       ClippingGlb:=true;
  183.       with window[WindowNdxGlb] do
  184.        begin
  185.         X1RefLoc2:=x1;
  186.         X2RefLoc2:=x2;
  187.         Y1RefLoc2:=y1;
  188.         Y2RefLoc2:=y2;
  189.        end;
  190.       ReDefineWindow(WindowNdxGlb,X1RefLoc2+4,Y1RefLoc2+6,
  191.       X2RefLoc2-2,Y2RefLoc2-14);
  192.       SelectWindow(WindowNdxGlb);
  193.       DirectModeGlb:=false;
  194.       if (XAxis>=0) then
  195.        begin
  196.         SetLineStyle(XAxis);
  197.         DrawLine(X1WldGlb,Y1WldGlb+Y2WldGlb,X2WldGlb,
  198.         Y1WldGlb+Y2WldGlb);
  199.         SetLineStyle(0);
  200.        end;
  201.       if (YAxis>=0) then
  202.        begin
  203.         SetLinestyle(YAxis);
  204.         DrawLine(0,Y1WldGlb,0,Y2WldGlb);
  205.         SetLineStyle(0);
  206.        end;
  207.       ClippingGlb:=ClippingLoc;
  208.       DirectModeGlb:=true;
  209.       ReDefineWindow(WindowNdxGlb,X1RefLoc2,Y1RefLoc2,
  210.       X2RefLoc2,Y2RefLoc2);
  211.       SelectWindow(WindowNdxGlb);
  212.      end;
  213.  
  214.    if Arrows then
  215.        begin
  216.         DrawLine(xk2,yk2,xk2-4,yk2-4);
  217.         DrawLine(xk2,yk2,xk2-4,yk2+4);
  218.        end;
  219.      end;
  220.     if (abs(yk0-yk1)>=35) and (abs(xk2-xk1)>=150) then
  221.      begin
  222.       DrawLine(xk0,yk0,xk0-4,yk0);
  223.       DrawLine(xk0,yk0,xk0,yk0+4);
  224.       Delta:=Y2RefGlb-Y1RefGlb-20;
  225.       NPoints:=Delta div 7;
  226.       NDiff:=Delta-(NPoints shl 3)+NPoints;
  227.       if YDens>=4 then
  228.        begin
  229.         if abs(Y2WldGlb)>abs(Y1WldGlb) 
  230.         then MaxExponentY:=GetExponent(Y2WldGlb)
  231.         else MaxExponentY:=GetExponent(Y1WldGlb);
  232.         DrawNum(X1RefGlb shl 3,yk0+1,MaxExponentY,Y1WldGlb);
  233.         if MaxExponentY<>0 
  234.         then DrawExponent(X1RefGlb shl 3+1,yk1+2,MaxExponentY);
  235.        end;
  236.       Fract:=NDiff/NPoints;
  237.       s:=-Fract;
  238.       ys:=yk0;
  239.       Difference:=(Y2WldGlb-Y1WldGlb)/NPoints;
  240.       for i:=1 to NPoints do
  241.        begin
  242.         ys:=ys-7-Balance;
  243.         if (YDens>2) and (ys>Y1RefGlb+13) then
  244.          begin
  245.           Number:=Y1WldGlb+i*Difference;
  246.           DrawLine(xk0,ys,xk0-4,ys);
  247.           if YDens>=4 then if i mod (10-YDens)=0 then
  248.             DrawNum(X1RefGlb shl 3,ys+1,MaxExponentY,Number);
  249.          end;
  250.        end;
  251.       if XDens>=4 then
  252.        begin
  253.         if abs(X2WldGlb)>abs(X1WldGlb) 
  254.         then MaxExponentX:=GetExponent(X2WldGlb)
  255.         else MaxExponentX:=GetExponent(X1WldGlb);
  256.         DrawNum(xk0-14,yk0+10,MaxExponentX,X1WldGlb);
  257.         if MaxExponentX<>0 
  258.         then DrawExponent(xk2-13,yk0+10,MaxExponentX);
  259.        end;
  260.  
  261.       Delta:=abs(X2RefGlb-X1RefGlb) shl 3-41;
  262.       NPoints:=Delta div 30;
  263.       NDiff:Delta-(NPoints shl 5)+(NPoints shl 1);         
  264.       Fract:+NDiff/NPoints;
  265.       s:=-Fract;
  266.       xs:=xko-1;
  267.       Difference:=(X2WldGlb)/NPoints;
  268.       for i:=1 to NPoints do
  269.        begin
  270.         xs:=xs+30+Balance:
  271.         if (XDens>2) and (xs<2RefGlb shl 3+7-24) then 
  272.          begin
  273.           Number:=X1WldGlb+i*Difference;
  274.           DrawLine(xs,yk0,xs,yk0+4);
  275.           if XDens>=4 then if i mod (10-XDens)=0 then
  276.             DrawNum(xs-14,yk0+10,MaxExponentX,Number);
  277.          end;
  278.        end;
  279.      end;
  280.      ReDefineWindow(WindowNdxGlb,X1RefLoc,Y1RefLoc,
  281.      X2RefLoc,Y2RefLoc);
  282.      SelectWindow(WindowNdxGlb);
  283.      DirectModeGlb:=DirectModeLoc;
  284.      SetLineStyle(LineStyleLoc);
  285.  
  286.                    |---{ ***** INSERT THE FOLLOWING BLOCK. *****}
  287.       <------------|
  288.                    | AxisGlb := true;
  289.                    | X1Glb := XLeft;
  290.                    | X2Glb := XRight;
  291.                    | Y1Glb := YTop;
  292.                    | Y2Glb := YBottom;
  293.                    |
  294.                    |---{ ***************************************}
  295.   end;
  296.  
  297.   {***** APPEND THE FOLLOWING PROCEDURE TO AXIS.HGH *****}
  298.  
  299. procedure ResetAxis;
  300.   begin
  301.     AxisGlb := true;
  302.   end;
  303.  
  304.   (***********************************************************)
  305.   (*                                                         *)
  306.   (*              TURBO GRAPHIX version 1.03A                *)
  307.   (*                                                         *)
  308.   (*                Polygon drawing module                   *)
  309.   (*                 Module version 1.03A                    *)
  310.   (*                                                         *)
  311.   (*                Copyright  (C) 1985 by                   *)
  312.   (*                BORLAND   International                  *)
  313.   (***********************************************************)
  314. ********************( CHANGE 1.03A TO 1.05A )********************
  315.  
  316. procedure DrawPolygon(A:PlotArray;
  317.                       I0,NPoints,Line,Scale,Lines:integer);
  318.   var i,x1,x2,y1,y2,XOffset,YOffset:integer;
  319.       X1RefLoc,Y1RefLoc,X2RefLoc,Y2RefLoc:integer;
  320.       DeltaY,XOs1,XOs2,YOs1,YOs2:integer;
  321.       AutoClip,DirectModeLoc,PlotLine,PlotSymbol:boolean;
  322.  
  323.       X1Loc,Y1Loc,X2Loc,Y2Loc:integer; <--{***** INSERT THIS LINE. *****}
  324.  
  325.  
  326.   procedure DrawPointClipped(x,y:integer);
  327.     begin
  328.       if (x1>X1RefGlb shl 3) and (x2<X2RefGlb shl 3+7) then
  329.         if (y1>Y1RefGlb) and (y2<Y2RefGlb) then dp(x,y);
  330.     end;
  331.  
  332.   procedure DrawItem(X,Y:integer);
  333.     var LineStyleLoc:integer;
  334.  
  335.     begin
  336.       LineStyleLoc:=LineStyleGlb;
  337.       SetLineStyle(0);
  338.       case Line of
  339.         2: DrawCrossDiag(X,Y,Scale);
  340.         3,4: DrawSquareC(X-Scale,Y+Scale,X+Scale,Y-Scale,(Line=4));
  341.         5: DrawDiamond(X,Y,Scale+1);
  342.         6: DrawWye(X,Y,Scale+1);
  343.         1: DrawCross(X,Y,Scale);
  344.         8: DrawCircleDirect(X,Y,Scale+1,False);
  345.         9: begin
  346.              PlotLine:=false;
  347.              if AutoClip then DrawPointClipped(X,Y)
  348.              else dp(X,Y);
  349.            end;
  350.         7: DrawStar(X,Y,Scale);
  351.        end;
  352.       SetLineStyle(LineStyleLoc);
  353.     end;
  354.  
  355.   begin
  356.     if abs(NPoints-I0)>=2 then
  357.      begin
  358.          <-------------|{***** INSERT THE FOLLOWING BLOCK. *****}
  359.                        |
  360.                        | X1Loc := X1Glb;
  361.                        | Y1Loc := Y1Glb;
  362.                        | X2Loc := X2Glb;
  363.                        | Y2Loc := Y2Glb;
  364.                        |
  365.                        |{***************************************}
  366.  
  367.       DirectModeLoc:=DirectModeGlb;
  368.       DirectModeGlb:=true;
  369.       AutoClip:=(NPoints<0);
  370.       NPoints:=abs(NPoints);
  371.       XOs1:=1;
  372.       XOs2:=1;
  373.       YOs1:=6;
  374.       YOs2:=6;
  375.       if AxisGlb then
  376.        begin
  377.         XOs1:=4;
  378.         XOs2:=2;
  379.         YOs1:=6;
  380.         YOs2:=14;
  381.         if (((X2RefGlb+7-XOs2-X1RefGlb+XOs2) > (XOs1+XOs2) shl 1) and
  382.            (Y2RefGlb-YOs2-Y1RefGlb+YOs1 > (YOs1+YOs2) shl 1)) then
  383.          begin
  384.           X1RefLoc:=X1RefGlb;
  385.           x1:=X1RefGlb+XOs1+X1Glb;
  386.           Y1RefLoc:=Y1RefGlb;
  387.           y1:=Y1RefGlb+YOs1+Y1Glb;
  388.           X2RefLoc:=X2RefGlb;
  389.           x2:=X2RefGlb-XOs2-X2Glb;
  390.           Y2RefLoc:=Y2RefGlb;
  391.           y2:=Y2RefGlb-YOs2-Y2Glb;
  392.           ReDefineWindow(WindowNdxGlb,x1,y1,x2,y2);
  393.           SelectWindow(WindowNdxGlb);
  394.  
  395.            <-----------------|{***** INSERT THE FOLLOWING LINE. *****}
  396.                              |
  397.                              | AxisGlb := true;
  398.                              |
  399.                              |{**************************************}
  400.          end;
  401.        end;
  402.       PlotLine:=(Line>=0);
  403.       PlotSymbol:=(Line<>0);
  404.       Line:=abs(Line);
  405.       Scale:=abs(Scale);
  406.  
  407.     if Lines<0 then DeltaY:=trunc(1.0/(abs(Y1WldGlb)+abs
  408.                                  (Y2WldGlb)) *
  409.                             abs(Y1WldGlb) * abs
  410.                                  (Y2RefGlb-Y1RefGlb))+1
  411.    else DeltaY:=0;
  412.    if (NPoints<2) and MessageGlb then
  413.      writeln('<DrawPolygon>: too few data pairs -> (NPoints) >= 2')
  414.    else
  415.     begin
  416.      x1:=WindowX(A[I0,1]);
  417.      y1:=Y2RefGlb+Y1RefGlb-WindowY(A[I0,2]);
  418.      DrawItem(x1,y1);
  419.      if Abs(Lines)=1 then
  420.        if AutoClip then DrawLineClipped(x1,Y2RefGlb-DeltaY,x1,y1)
  421.        else DrawLine(x1,Y2RefGlb-DeltaY,x1,y1);
  422.      for i:=I0+1 to NPoints do
  423.       begin
  424.        x2:=WindowX(A[i,1]);
  425.        y2:=Y2RefGlb+Y1RefGlb-WindowY(A[i,2]);
  426.        DrawItem(x2,y2);
  427.        if Abs(Lines)=1 then
  428.          if AutoClip then DrawLineClipped(x2,Y2RefGlb-DeltaY,x2,y2)
  429.          else DrawLine(x2,Y2RefGlb-DeltaY,x2,y2);
  430.        if PlotLine then
  431.          if AutoClip then DrawLineClipped(x1,y1,x2,y2)
  432.          else DrawLine(x1,y1,x2,y2);
  433.        x1:=x2;
  434.        y1:=y2;
  435.       end;
  436.     end;
  437.    if AxisGlb then
  438.     begin
  439.      ReDefineWindow(WindowNdxGlb,X1RefLoc,Y1RefLoc,X2RefLoc,Y2RefLoc);
  440.      SelectWindow(WindowNdxGlb);
  441.        <------------------|{***** INSERT THE FOLLOWING BLOCK. *****}
  442.                           |
  443.                           | X1Glb := X1Loc;
  444.                           | Y1Glb := Y1Loc;
  445.                           | X2Glb := X2Loc;
  446.                           | Y2Glb := Y2Loc;
  447.                           |
  448.                           |{***************************************}
  449.      AxisGlb:=false;
  450.    end;
  451.    DirectModeGlb:=DirectModeLoc;
  452.   end
  453.  else error(18,4);
  454. end;
  455.  
  456.                           HISTOGRM.HGH
  457.   (***********************************************************)
  458.   (*                                                         *)
  459.   (*               TURBO GRAPHIX version 1.03A               *)
  460.   (*                                                         *)
  461.   (*                    Bar chart module                     *)
  462.   (*                 Module  version  1.03A                  *)
  463.   (*                                                         *)
  464.   (*                 Copyright (C) 1985 by:                  *)
  465.   (*                 BORLAND  International                  *)
  466.   (*                                                         *)
  467.   (***********************************************************)
  468. *******************( CHANGE 1.03A TO 1.05A ) *********************
  469.  
  470. procedure DrawHistogram(A:PlotArray;
  471.                         NPoints:integer;
  472.                         Hatching:boolean;
  473.                         HatchStyle:integer);
  474.  
  475.   var x1,x2,y2,NPixels,Delta,NDiff,YRef:integer;
  476.       LineStyleLoc,i:integer;
  477.       Fract,s,y,YAxis:real;
  478.       DirectModeLoc,Negative:boolean;
  479.       wtemp:WindowType;
  480.        <------------------|{***** INSERT THE FOLLOWING LINE. *****}
  481.                           |
  482.                           | X1Loc,Y1Loc,X2Loc,Y2Loc:integer;
  483.                           |
  484.                           |{**************************************}
  485.    function Balance:integer;
  486.     begin
  487.       Balance:=0;
  488.       s:=s+Fract;
  489.       if s>=0.0 then
  490.        begin
  491.         s:=s-1.0;
  492.         Balance:=1;
  493.        end;
  494.     end;
  495.  
  496.   begin { DrawHistogram }
  497.     if abs(NPoints)>=2 then
  498.      begin
  499.  
  500.       <--------------------|{***** INSERT THE FOLLOWING BLOCK. *****}
  501.                            |
  502.                            | X1Loc := X1Glb;
  503.                            | Y1Loc := Y1Glb;
  504.                            | X2Loc := X2Glb;
  505.                            | Y2Loc := Y2Glb;
  506.                            |
  507.                            |{***************************************}
  508.  
  509.       LineStyleLoc:=LinestyleGlb;
  510.       SetLineStyle(0);
  511.       if AxisGlb then
  512.        begin
  513.         wtemp:=window[WindowNdxGlb];
  514.         ReDefineWindow(WindowNdxGlb,X1RefGlb+4+X1Glb,
  515.                        Y1RefGlb+6+Y1Glb,
  516.                        X2RefGlb-2-X2Glb,Y2RefGlb-14-Y2Glb);
  517.         SelectWindow(WindowNdxGlb);
  518.  
  519.         <----------------|{*****  INSERT THE  FOLLOWING  LINE. *****}
  520.                          |
  521.                          | AxisGlb := true;
  522.                          |
  523.                          |{**************************************}
  524.        end;
  525.       DirectModeLoc:=DirectModeGlb;
  526.       DirectModeGlb:=true;
  527.       Negative:=NPoints<0;
  528.       NPoints:=abs(NPoints);
  529.       NPixels:=(X2RefGlb-X1RefGlb) shl 3+7;
  530.       Delta:=NPixels div NPoints;
  531.       NDiff:=NPixels-Delta*NPoints;
  532.       Fract:=NDiff/NPoints;
  533.       s:=-Fract;
  534.       x1:=X1RefGlb shl 3;
  535.       YRef:=trunc(Y2RefGlb+Y1RefGlb-AyGlb);
  536.       if Negative then DrawStraight(x1,X2RefGlb shl 3+7,YRef);
  537.       YAxis:=Y1RefGlb;
  538.       if BYGlb>0 then YAxis:=Y2RefGlb;
  539.       for i:=1 to NPoints do
  540.        begin
  541.         x2:=x1+Delta+Balance;
  542.         y:=A[i,2];
  543.         if not Negative then y:=abs(y);
  544.         if AxisGlb then y2:=trunc(AyGlb+ByGlb*y)
  545.         else y2:=trunc((AyGlb+ByGlb*y)*0.99);
  546.         y2:=Y2RefGlb+Y1RefGlb-y2;
  547.         if not Negative then
  548.          begin
  549.           DrawLine(x1,YAxis,x1,y2);
  550.           DrawStraight(x1,x2,y2);
  551.           DrawLine(x2,y2,x2,YAxis);
  552.           if Hatching then
  553.             if odd(i) then hatch(x1,y2,x2,YAxis,HatchStyle)
  554.             else hatch(x1,y2,x2,YAxis,-HatchStyle);
  555.          end
  556.         else
  557.          begin
  558.           DrawLine(x1,YRef,x1,y2);
  559.           DrawStraight(x1,x2,y2);
  560.           DrawLine(x2,y2,x2,YRef);
  561.  
  562.           if Hatching then
  563.             if odd(i) then hatch(x1,y2,x2,YAxis,HatchStyle)
  564.             else hatch(x1,y2,x2,YAxis,-HatchStyle);
  565.          end
  566.         else
  567.          begin
  568.           DrawLine(x1,YRef,x1,y2);
  569.           DrawStraight(x1,x2,y2);
  570.           DrawLine(x2,y2,x2,YRef);
  571.           if Hatching then
  572.             if YRef-y2<0 then
  573.               if odd(i) then hatch(x1,YRef,x2,y2,HatchStyle)
  574.               else hatch(x1,YRef,x2,y2,-HatchStyle)
  575.             else if odd(i) then hatch(x1,y2,x2,YRef,HatchStyle)
  576.             else hatch(x1,y2,x2,YRef,-HatchStyle);
  577.          end;
  578.         x1:=x2;
  579.        end;
  580.       if AxisGlb then
  581.        begin
  582.         window[WindowNdxGlb]:=wtemp;
  583.         SelectWindow(WindowNdxGlb);
  584.  
  585.          <-------------|{***** INSERT THE FOLLOWING BLOCK. *****}
  586.                        |
  587.                        | X1Glb := X1Loc;
  588.                        | Y1Glb := Y1Loc;
  589.                        | X2Glb := X2Loc;
  590.                        | Y2Glb := Y2Loc;
  591.                        |
  592.                        |{***************************************}
  593.  
  594.         AxisGlb:=false;
  595.        end;
  596.       DirectModeGlb:=DirectModeLoc;
  597.       SetLineStyle(LineStyleLoc);
  598.      end
  599.     else error(19,4);
  600.   end;
  601.