home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / nvdc87 / units / box.pas next >
Pascal/Delphi Source File  |  1987-08-18  |  3KB  |  107 lines

  1. UNIT Box;
  2.  
  3. (*
  4.  *      PURPOSE : A Unit for displaying boxes
  5.  *      SYSTEM  : IBM PC/MS-DOS, Turbo Pascal 4.0
  6.  *      AUTHOR  : Tom Swan
  7.  *)
  8.  
  9.  
  10. INTERFACE
  11.  
  12. USES    Crt;
  13.  
  14. VAR     TopLine:                CHAR;   { Horiz. top line char }
  15.         LeftLine:               CHAR;   { Vert. left line char }
  16.         BottomLine:             CHAR;   { Horiz. bottom line char }
  17.         RightLine:              CHAR;   { Vert. right line char }
  18.  
  19.         TopLeftCorner:          CHAR;   { Top left corner char }
  20.         TopRightCorner:         CHAR;   { Top right corner char }
  21.         BottomLeftCorner:       CHAR;   { Bottom left corner char }
  22.         BottomRightCorner:      CHAR;   { Bottom right corner char }
  23.  
  24.  
  25. PROCEDURE DrawBox( Top, Left, Bottom, Right : INTEGER );
  26.  
  27. { Call this procedure to draw a box, using the global character
  28.   variables.  The four parameters are not checked.  Using values
  29.   outside the legal display coordinates will produce strange-
  30.   looking boxes! }
  31.  
  32.  
  33. { ----------------------------------------------------------------- }
  34.  
  35. IMPLEMENTATION
  36.  
  37.  
  38. CONST   DefTop=                 #205;
  39.         DefLeft=                #179;
  40.         DefBottom=              #196;
  41.         DefRight=               #179;
  42.  
  43.         DefTopLeft=             #213;
  44.         DefTopRight=            #184;
  45.         DefBottomLeft=          #192;
  46.         DefBottomRight=         #217;
  47.  
  48.  
  49.  
  50. PROCEDURE DrawBox(* ( Top, Left, Bottom, Right : INTEGER ) *);
  51.  
  52. { Draw rectangular outline pegged to these coordinate values. }
  53.  
  54. VAR     x, y : INTEGER;    { Temporary screen coordinates }
  55.  
  56. BEGIN
  57.  
  58.         { First, draw the box's four corners }
  59.  
  60.         GotoXY( Left, Top );            { Top, Left }
  61.          Write( TopLeftCorner );
  62.         GotoXY( Right, Top );           { Top, Right }
  63.          Write( TopRightCorner );
  64.         GotoXY( Left, Bottom );         { Bottom, Left }
  65.          Write( BottomLeftCorner );
  66.         GotoXY( Right, Bottom );        { Bottom, Right }
  67.          Write( BottomRightCorner );
  68.  
  69.  
  70.         { Next, fill in the top and bottom sides }
  71.  
  72.         GotoXY( Left + 1, Top );
  73.         FOR x := ( Left + 1 ) TO ( Right - 1 ) DO
  74.                 Write( TopLine );
  75.  
  76.         GotoXY( Left + 1, Bottom );
  77.         FOR x := ( Left + 1 ) TO ( Right - 1 ) DO
  78.                 Write( BottomLine );
  79.  
  80.  
  81.         { And then fill in the left and right sides }
  82.  
  83.         FOR y := ( Top + 1 ) TO ( Bottom - 1 ) DO BEGIN
  84.                 GotoXY( Left, y );
  85.                 Write( LeftLine );
  86.                 GotoXY( Right, y );
  87.                 Write( RightLine )
  88.         END { for }
  89.  
  90. END; { DrawBox }
  91.  
  92.  
  93.  
  94. BEGIN   { Unit initialization }
  95.  
  96.         TopLine := DefTop;              { Assign default character }
  97.         LeftLine := DefLeft;            {  values to global vars.  }
  98.         BottomLine := DefBottom;
  99.         RightLine := DefRight;
  100.  
  101.         TopLeftCorner := DefTopLeft;
  102.         TopRightCorner := DefTopRight;
  103.         BottomLeftCorner := DefBottomLeft;
  104.         BottomRightCorner := DefBottomRight
  105.  
  106. END.    { Box unit }
  107.