home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / PROGRAMM / BUILDER.ZIP / DOBOX.BLD < prev    next >
Text File  |  1992-12-02  |  6KB  |  226 lines

  1. '==================================================================
  2. ' DOBOX.BLD
  3. '
  4. ' What it does:
  5. '   DOBOX lets you draw and resize a box onscreen.  When you're
  6. '   satisfied with the box, press {F} and a file is created
  7. '   consisting of the BOX statement you need to display the box
  8. '   you've just created.
  9. '
  10. '   To get help, press:  {F1}
  11. '   -------------------------
  12. '
  13. '   To move box, press:
  14. '   -------------------------
  15. '   Up                  {PgUp}
  16. '   Down                {PgDn}
  17. '   Right         {Ctrl-Right}
  18. '   Left           {Ctrl-Left}
  19. '
  20. '   To stretch it, press:
  21. '   --------------------------
  22. '   Horizontally       {Right}
  23. '   Vertically          {Down}
  24. '
  25. '   To shrink it, press:
  26. '   --------------------------
  27. '   Horizontally        {Left}
  28. '   Vertically            {Up}
  29. '
  30. '   And...
  31. '   --------------------------
  32. '   To get help           {F1}
  33. '   To save as a file      {F}
  34. '   To switch box type     {B}
  35. '
  36. ' Tested using:
  37. '   Builder 1.21
  38. '
  39. ' By:
  40. '   Tom Campbell
  41. '
  42. '==================================================================
  43.  
  44. ' Reserve space for a file descriptor.
  45. File OutFile
  46. ' BoxType is either 1 or 2, for single or double box.
  47. ' Row, Col, Height, and Width are the box's coordinates.
  48. Integer BoxType, Row, Col, Height, Width
  49. ' Filename is the actual name of the file, such as BOX.BLD.
  50. ' You can't write integer variables to a file; they must first
  51. ' be converted to strings.  These are the string names that
  52. ' correspond with those variables.
  53. String Filename, SRow, SCol, SHeight, SWidth
  54. ' Start the box out in the middle of the screen.
  55. Row := 8
  56. Col := 35
  57. ' It's a fairly small box to start with.
  58. Height := 8
  59. Width := 10
  60. ' Use single-width box as default
  61. BoxType := 1
  62. ' Disable the hardware cursor.
  63. Don't use the cursor
  64. ' Clear the screen.
  65. cls
  66.  
  67.  
  68. ' Draw the box for the first time.
  69. Redraw
  70. ' Draw the help line, with box coordinates, help msg, etc.
  71. DrawBottomLine
  72. While Not Canceled
  73.   GetKey
  74.   Select LastKey From
  75.  
  76.     Case {Left} :     ' Shrink the box horizontally.
  77.       If Width > 3
  78.         Undraw
  79.         Put Width - 1 into Width
  80.         Redraw
  81.       End ' If Width > 3
  82.  
  83.     Case {Right} :     ' Stretch the box horizontally.
  84.       Undraw
  85.       Put Width + 1 into Width
  86.       Redraw
  87.  
  88.     Case {Up} :        ' Shrink the box vertically.
  89.       Undraw
  90.       If Height > 3 Put Height - 1 into Height
  91.       Redraw
  92.  
  93.     Case {Down} :      ' Stretch the box vertically.
  94.       Undraw
  95.       Put Height + 1 into Height
  96.       Redraw
  97.  
  98.     Case {Ctrl-Right} :' Move the box to the right.
  99.       Undraw
  100.       Put Col + 1 into Col
  101.       Redraw
  102.  
  103.     Case {Ctrl-Left} :     ' Move the box to the left.
  104.       Undraw
  105.       If Col > 0 Put Col - 1 into Col
  106.       Redraw
  107.  
  108.     Case {PgUp} :     ' Move the box up.
  109.       Undraw
  110.       If Row > 1 Put Row - 1 into Row
  111.       Redraw
  112.  
  113.     Case {PgDn} :     ' Move the box down.
  114.       Undraw
  115.       Put Row + 1 into Row
  116.       Redraw
  117.  
  118.     Case {b} :
  119.       If BoxType is 1
  120.         BoxType := 2
  121.         Redraw
  122.       end else
  123.         BoxType := 1
  124.         Redraw
  125.       End
  126.  
  127.     Case {B} :
  128.       If BoxType is 1
  129.         BoxType := 2
  130.         Redraw
  131.       end else
  132.         BoxType := 1
  133.         Redraw
  134.       End
  135.  
  136.     Case {F} :              ' Create a file.
  137.       CreateFile
  138.        RedrawWholeScreen
  139.  
  140.     Case {f} :              ' Create a file.
  141.       CreateFile
  142.       RedrawWholeScreen
  143.  
  144.     case {F1} :
  145.       DoHelp
  146.       GetKey
  147.       RedrawWholeScreen
  148.   End ' Select
  149. End ' While Not Canceled
  150. Use the cursor
  151.  
  152. Sub Undraw
  153.   If BoxType is 1
  154.     Single Box Row, Col, Width, Height Black On Black
  155.   end else
  156.     Double Box Row, Col, Width, Height Black On Black
  157.   End
  158. End ' Sub Undraw
  159.  
  160. Sub Redraw
  161.   If BoxType is 1
  162.     Single Box Row, Col, Width, Height White On Black
  163.   end else
  164.     Double Box Row, Col, Width, Height White On Black
  165.   End
  166.   RowCol 23, 1
  167.   Repeat 60
  168.     Say " ";
  169.   End ' Repeat
  170.   say @ 23, 1 "Row="; Row; " Col="; Col; " Width="; Width; " Height="; Height
  171. End ' Sub Redraw
  172.  
  173. Sub CreateFile
  174.   say @ 3, 1 "File to create? ";
  175.   Repeat 64
  176.     Say "▓";
  177.   End ' Repeat
  178.   RowCol 3, 17
  179.   Input Filename
  180.   If Not Canceled
  181.     Open Filename for Writing as OutFile
  182.     SRow := IntToStr Row
  183.     SCol := IntToStr Col
  184.     SHeight := IntToStr Height
  185.     SWidth := IntToStr Width
  186.     WriteLine "Single box "+SRow+","+SCol+","+SWidth+","+SHeight+" White on Black" to OutFile
  187.     Close OutFile
  188.   End ' If Not Canceled
  189. End
  190.  
  191. Sub DoHelp
  192.   Double box 2, 23,36,23 White on Black
  193.   Say @  5, 28 "<reverse>       To move box, press:"
  194.   Say @  6, 28 "Up                  {PgUp}"
  195.   Say @  7, 28 "Down                {PgDn}"
  196.   Say @  8, 28 "Right         {Ctrl-Right}"
  197.   Say @  9, 28 "Left           {Ctrl-Left}"
  198.   Say @ 11, 28 "<reverse>    To stretch it, press:"
  199.   Say @ 12, 28 "Horizontally       {Right}"
  200.   Say @ 13, 28 "Vertically          {Down}"
  201.   Say @ 15, 28 "<reverse>     To shrink it, press:"
  202.   Say @ 16, 28 "Horizontally        {Left}"
  203.   Say @ 17, 28 "Vertically            {Up}"
  204.  
  205.   Say @ 19, 28 "<reverse>                   And..."
  206.   Say @ 20, 28 "To save as a file      {F}"
  207.   Say @ 21, 28 "To switch box type     {B}"
  208.   GetKey
  209.  
  210. End ' SubDoHelp
  211.  
  212. Sub DrawBottomLine
  213.   RowCol 24, 1
  214.   Repeat 79
  215.     Say "░";
  216.   End ' Repeat
  217.   Say @ 24, 9 "{F1}=Help  {F}=Create file {Esc}=Quit {B}=Box type"
  218. End ' Sub DrawBottomLine
  219.  
  220. Sub RedrawWholeScreen
  221.   Cls
  222.   DrawBottomLine
  223.   Redraw
  224. End ' Sub RedrawWholeScreen
  225.  
  226.