home *** CD-ROM | disk | FTP | other *** search
/ Ray Tracing Box / RAY_CD.mdf / ray_util / showpic / john_sub.bas < prev    next >
BASIC Source File  |  1994-02-10  |  5KB  |  215 lines

  1. '*****************************JOHN_SUB.BAS********************************
  2. 'JOHN :
  3. 'Trying to get modular
  4. 'This contains the subs and functions I use all the time
  5. '2/7/94
  6. '
  7. 'There is no main module in this *.BAS file.
  8.  
  9. 'Declarations for Routines in JOHN_SUB.BAS
  10. DEFINT A-Z
  11. DECLARE SUB LocateIt (Row%, text$)
  12. DECLARE SUB ColorIt (Fgd%, Bkg%)
  13. DECLARE FUNCTION Center% (text$)
  14. DECLARE SUB CursorOff ()
  15. DECLARE SUB CursorOn ()
  16. DECLARE SUB Pause (Seconds!)
  17. DECLARE SUB ErrorBox (Row%)
  18. DECLARE SUB TextBox (Row%, Col%, Message$, Outline%, Length%)
  19. DECLARE SUB Waitkey ()
  20. DECLARE SUB WidenMsg (MsgLength%, Message$)
  21.  
  22. Copyright$ = "■Copyright (c) 1994 ■ John De Palma■"
  23.  
  24. FUNCTION Center% (text$)
  25. Center% = 41 - LEN(text$) \ 2
  26. END FUNCTION
  27.  
  28. SUB ColorIt (Fgd, Bkg)
  29. COLOR Fgd, Bkg
  30. END SUB
  31.  
  32. SUB CursorOff
  33. LOCATE , , 0
  34. END SUB
  35.  
  36. SUB CursorOn
  37. LOCATE , , 1, 4, 7
  38. END SUB
  39.  
  40. SUB ErrorBox (Row%)
  41.  
  42. CALL ColorIt(15, 4)
  43.  
  44. text$ = "█▀▀▀▀▀▀▀▀▀▀▀▀▀█"
  45. CALL LocateIt(Row%, text$)
  46. text$ = "█    ERROR    █"
  47. CALL LocateIt(Row% + 1, text$)
  48. text$ = "█▄▄▄▄▄▄▄▄▄▄▄▄▄█"
  49. CALL LocateIt(Row% + 2, text$)
  50.  
  51. END SUB
  52.  
  53. SUB LocateIt (Row%, text$)
  54. LOCATE Row%, Center(text$)
  55. PRINT text$;
  56. END SUB
  57.  
  58. DEFSNG A-Z
  59. SUB Pause (Seconds!)
  60.    
  61.     Synch! = TIMER
  62.     DO                          'looping changes the Start! time to
  63.         Start! = TIMER          'synchronize to the system timer
  64.     LOOP WHILE Start! = Synch!  'Seconds! must be SINGLE to get fractions
  65.                                 'of a second
  66.     DO
  67.         Kee$ = INKEY$
  68.     LOOP UNTIL TIMER > (Start! + Seconds!) OR LEN(Kee$)
  69.                                
  70.                                 'put Kee$ in just in case we pass midnight
  71.     WHILE INKEY$ <> "": WEND    'delete that key stroke
  72. END SUB
  73.  
  74. DEFINT A-Z
  75. SUB TextBox (Row%, Col%, Message$, Outline%, Length%)
  76.  
  77.     'Will put a message into a three line box -or-
  78.     'draw a box without a message using Message$=SPACE$(x)
  79.     'where "x" is the width of the box and Length%= number of lines > 3
  80.     'All boxes are centered.
  81.     'Now to make them non centered....
  82.  
  83.     Message$ = LEFT$(Message$, 60)
  84.     BoxWidth% = LEN(Message$) + 4
  85.     SELECT CASE Outline%
  86.         CASE 0
  87.             j = 8 * 5 + 1
  88.         CASE 1
  89.             j = 1
  90.         CASE 2
  91.             j = 8 + 1
  92.         CASE 3
  93.             j = 8 * 2 + 1
  94.         CASE 4
  95.             j = 8 * 3 + 1
  96.         CASE 5
  97.             j = 8 * 4 + 1
  98.         CASE ELSE
  99.             j = 8 * 5 + 1
  100.     END SELECT
  101.    
  102.     DIM Box$(1 TO 8 * 6)
  103.  
  104. 'single line box
  105.     Box$(1) = "┌"
  106.     Box$(2) = "─"
  107.     Box$(3) = "┐"
  108.     Box$(4) = "│"
  109.     Box$(5) = "│"
  110.     Box$(6) = "└"
  111.     Box$(7) = "─"
  112.     Box$(8) = "┘"
  113.  
  114. 'double top box
  115.     Box$(9) = "╒"
  116.     Box$(10) = "═"
  117.     Box$(11) = "╕"
  118.     Box$(12) = "│"
  119.     Box$(13) = "│"
  120.     Box$(14) = "╘"
  121.     Box$(15) = "═"
  122.     Box$(16) = "╛"
  123.  
  124. 'double side box
  125.     Box$(17) = "╓"
  126.     Box$(18) = "─"
  127.     Box$(19) = "╖"
  128.     Box$(20) = "║"
  129.     Box$(21) = "║"
  130.     Box$(22) = "╙"
  131.     Box$(23) = "─"
  132.     Box$(24) = "╜"
  133.  
  134. 'double box
  135.     Box$(25) = "╔"
  136.     Box$(26) = "═"
  137.     Box$(27) = "╗"
  138.     Box$(28) = "║"
  139.     Box$(29) = "║"
  140.     Box$(30) = "╚"
  141.     Box$(31) = "═"
  142.     Box$(32) = "╝"
  143.  
  144. 'bold and thick box
  145.     Box$(33) = "█"
  146.     Box$(34) = "▀"
  147.     Box$(35) = "█"
  148.     Box$(36) = "█"
  149.     Box$(37) = "█"
  150.     Box$(38) = "█"
  151.     Box$(39) = "▄"
  152.     Box$(40) = "█"
  153.  
  154. 'no box
  155.     Box$(41) = " "
  156.     Box$(42) = " "
  157.     Box$(43) = " "
  158.     Box$(44) = " "
  159.     Box$(45) = " "
  160.     Box$(46) = " "
  161.     Box$(47) = " "
  162.     Box$(48) = " "
  163.    
  164.     IF Col% = 0 THEN
  165.        
  166.         BoxText$ = Box$(j) + STRING$(BoxWidth%, Box$(j + 1)) + Box$(j + 2)
  167.         CALL LocateIt(Row%, BoxText$)
  168.   
  169.         FOR i = 1 TO Length% + 1
  170.         BoxText$ = Box$(j + 3) + "  " + Message$ + "  " + Box$(j + 4)
  171.         CALL LocateIt(Row% + i, BoxText$)
  172.         NEXT i
  173.    
  174.         BoxText$ = Box$(j + 5) + STRING$(BoxWidth%, Box$(j + 6)) + Box$(j + 7)
  175.         CALL LocateIt(Row% + i, BoxText$)
  176.    
  177.     ELSE
  178.  
  179.         BoxText$ = Box$(j) + STRING$(BoxWidth%, Box$(j + 1)) + Box$(j + 2)
  180.         LOCATE Row%, Col%
  181.         PRINT BoxText$
  182.  
  183.         FOR i = 1 TO Length% + 1
  184.         BoxText$ = Box$(j + 3) + "  " + Message$ + "  " + Box$(j + 4)
  185.         LOCATE Row% + i, Col%
  186.         PRINT BoxText$
  187.         NEXT i
  188.   
  189.         BoxText$ = Box$(j + 5) + STRING$(BoxWidth%, Box$(j + 6)) + Box$(j + 7)
  190.         LOCATE Row% + i, Col%
  191.         PRINT BoxText$
  192.  
  193.     END IF
  194. END SUB
  195.  
  196. SUB Waitkey
  197.  
  198.     WHILE INKEY$ <> "": WEND
  199.     DO
  200.         Kee$ = INKEY$
  201.     LOOP UNTIL LEN(Kee$)
  202.     IF Kee$ = CHR$(27) THEN END
  203.  
  204. END SUB
  205.  
  206. SUB WidenMsg (MsgLength%, Message$)
  207. Length% = LEN(Message$)
  208. WHILE Length% < MsgLength%
  209.     Message$ = " " + Message$ + " "
  210.     Length% = LEN(Message$)
  211. WEND
  212.  
  213. END SUB
  214.  
  215.