home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / homonlib.zip / PANES.BAS < prev    next >
BASIC Source File  |  1995-04-13  |  7KB  |  155 lines

  1. DEFINT A-Z
  2.  
  3. ' $INCLUDE: 'TRUEFALS.INC'
  4.  
  5. DECLARE SUB Box (row1, col1, row2, col2, boxtype$)
  6. DECLARE SUB Panes (row1, col1, row2, col2, row3, col3, boxtype$)
  7.  
  8.  
  9. 'External Procedures:
  10.  
  11. DECLARE FUNCTION IsAlpha (s$)
  12.  
  13. SUB Box (row1, col1, row2, col2, boxtype$)
  14. '****************************************************************************
  15. 'Draws a box on the screen at the specified coordinates.  row1 & col1 are the
  16. ' top left corner, row2 & col2 are the bottom right corner.  The appearance
  17. ' of the box is determined by boxtype$, which can either be one character to
  18. ' pick a predefined box type or a string of 11 or more characters to be used
  19. ' as the actual box characters.  See the function body of Panes() for the
  20. ' exact placement of the characters within the string and other options.
  21. '
  22. 'Examples of boxtype$: "1" or "S"    Draws a single-line box (default)
  23. '                      "2" or "D"    Draws a double-line box
  24. '                      "3" or "H"    Double Horizontal lines, single vertical
  25. '                      "4" or "V"    Double Vertical lines, single horizontal
  26. '                      "***********" Draws a box made of asterisks
  27. '
  28. '****************************************************************************
  29.  
  30. 'Translate the call to Box() into a call to Panes() with no inner lines.
  31.  
  32. Panes row1, col1, row2, col2, 0, 0, boxtype$
  33.  
  34. END SUB
  35.  
  36. SUB Panes (row1, col1, row2, col2, row3, col3, boxtype$)
  37. '****************************************************************************
  38. 'Draws a box on the screen at the specified coordinates.  row1 & col1 are the
  39. 'top left corner, row2 & col2 are the bottom right corner.  row3 & col3 are
  40. 'parameters specifying where the box is to be split horizontally and/or
  41. 'vertically.  If either or both row3 or col3 are zero, the box will not be
  42. 'split in that direction.  Experiment with it.
  43. '
  44. 'The appearance of the box is determined by boxtype$, which can either be one
  45. 'character to pick a predefined box type or a string of 11 or more characters
  46. 'to be used as the actual box characters.  See the function body for the
  47. 'exact placement of the characters within the string.
  48. '
  49. 'Examples of boxtype$: "1" or "S"    Draws a single-line box (default)
  50. '                      "2" or "D"    Draws a double-line box
  51. '                      "3" or "H"    Double horizontal lines, single vertical
  52. '                      "4" or "V"    Double vertical lines, single horizontal
  53. '                      "***********" Draws a box made of asterisks
  54. '
  55. 'The box can be drawn as an outline only, not overwriting anything within the
  56. ' box's borders or can be filled with a fill character, effectively placing
  57. ' the box over whatever was already there.  This option is also controlled by
  58. ' the boxtype$ argument:
  59. '
  60. 'If boxtype$ is specified as a number ("1", "2"...) the box will be drawn as
  61. ' an outline only.  If boxtype$ is specified as a letter ("S", "D"...) the
  62. ' box will be filled with spaces.
  63. '
  64. 'If boxtype is a user-supplied string of characters, if it's length is 12 or
  65. ' more, the 12th character will be used as the fill character, otherwise the
  66. ' box will be drawn as an outline.
  67. '
  68. '****************************************************************************
  69.  
  70. '                     *** Define the box characters ***
  71.  
  72. x$ = "┌┐┘└│─┬┤┴├┼"                 'Default the box characters to single line
  73.  
  74. IF LEN(boxtype$) >= 11 THEN                                 'User-supplied
  75.      x$ = boxtype$                                          'box characters
  76. ELSE
  77.      SELECT CASE UCASE$(LEFT$(boxtype$, 1))
  78.           CASE "2", "D"                                     'Double
  79.                x$ = "╔╗╝╚║═╦╣╩╠╬"
  80.           CASE "3", "H"                                     'Horizontal dbl.
  81.                x$ = "╒╕╛╘│═╤╡╧╞╪"
  82.           CASE "4", "V"                                     'Vertical dbl.
  83.                x$ = "╓╖╜╙║─╥╢╨╟╫"
  84.           CASE ELSE                                         'Single (default)
  85.                'Use the pre-defined value of x$
  86.      END SELECT
  87.      IF IsAlpha(boxtype$) THEN                              'Fill the box if
  88.           x$ = x$ + " "                                     'boxtype$ is a
  89.      END IF                                                 'letter.
  90. END IF
  91.  
  92. '           *** Give descriptive names to the box characters ***
  93.  
  94. tlc$ = MID$(x$, 1, 1)         'Top Left Corner
  95. trc$ = MID$(x$, 2, 1)         'Top Right Corner
  96. brc$ = MID$(x$, 3, 1)         'Bottom Right Corner
  97. blc$ = MID$(x$, 4, 1)         'Bottom Left Corner
  98. ver$ = MID$(x$, 5, 1)         'Vertical line
  99. hor$ = MID$(x$, 6, 1)         'Horizontal line
  100. tx$ = MID$(x$, 7, 1)          'Top intersection
  101. rx$ = MID$(x$, 8, 1)          'Right intersection
  102. bx$ = MID$(x$, 9, 1)          'Bottom intersection
  103. lx$ = MID$(x$, 10, 1)         'Left intersection
  104. mx$ = MID$(x$, 11, 1)         'Middle intersection
  105. IF LEN(x$) > 11 THEN          'Fill character?
  106.      f$ = MID$(x$, 12, 1)
  107.      fill = TRUE
  108. END IF
  109.  
  110. '                           *** Draw the Box ***
  111.  
  112. wide = col2 - col1 - 1
  113.  
  114. across$ = STRING$(wide, hor$)                          'Call STRING$ only
  115. IF fill THEN f$ = STRING$(wide, f$)                    'one time each.
  116.  
  117. LOCATE row1, col1                                      'The main box outline:
  118. PRINT tlc$; across$; trc$;                             'The top line
  119. FOR x = (row1 + 1) TO (row2 - 1)                       'The sides
  120.      LOCATE x, col1
  121.      PRINT ver$;
  122.      IF fill THEN                                      'If the box is being
  123.           PRINT f$; ver$;                              'filled, put the fill
  124.      ELSE                                              'characters between
  125.           LOCATE x, col2                               'the sides. Otherwise
  126.           PRINT ver$;                                  'just skip that area.
  127.      END IF
  128. NEXT x
  129. LOCATE row2, col1                                      'The bottom line
  130. PRINT blc$; across$; brc$;
  131.  
  132. IF row3 > 0 THEN                                       'Split horizontally?
  133.      LOCATE row3, col1
  134.      PRINT lx$; across$; rx$;
  135. END IF
  136.  
  137. IF col3 > 0 THEN                                       'Split vertically?
  138.      LOCATE row1, col3
  139.      PRINT tx$;
  140.      FOR x = (row1 + 1) TO (row2 - 1)
  141.           LOCATE x, col3
  142.           PRINT ver$;
  143.      NEXT x
  144.      LOCATE row2, col3
  145.      PRINT bx$;
  146. END IF
  147.  
  148. IF row3 > 0 AND col3 > 0 THEN                          'Split both ways?
  149.      LOCATE row3, col3
  150.      PRINT mx$
  151. END IF
  152.  
  153. END SUB
  154.  
  155.