home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / bounceb.zip / BOUNCE.BAS < prev    next >
BASIC Source File  |  1992-12-31  |  6KB  |  186 lines

  1.  
  2. 'Bounce.BAS    Jim Paisley  10690 Allen Rd NW  Washington C.H., Oh, 43160
  3.  
  4. '-------------------subs from WMouse.OBJ---------------------------
  5. DECLARE SUB ShowM : 'see note at end of this program
  6.  
  7. DECLARE SUB HideM
  8. DECLARE SUB MButton (l%, r%) : 'returned as true/false
  9. DECLARE SUB MLoc (r%, c%) : ' r% = 0 to 199  c% = 0 to 639
  10. DECLARE SUB SetMLoc (r%, c%)
  11. DECLARE SUB InitM (Present%) : ' -1 if mouse driver not present
  12.  
  13. '-------------- subs from QB4Win32.ZIP ------------------------------
  14.  
  15.     '$INCLUDE: 'W32.DEC'
  16.  
  17. '----------------------------------------------------------------------
  18.     SCREEN 0
  19.     COLOR 2, 0: CLS
  20.        
  21.     InitM p%: IF p% <> -1 THEN PRINT "No Mouse installed": END
  22. '-----------------------------------------------------------------------
  23. MainProgram:   
  24.     fore = 0: back = 3: Bright = 11
  25.     Kolor fore, back: Lokate 1, 1:
  26.     Prnt "          File                    " + CHR$(10)
  27.  
  28.     'print directions
  29.     COLOR 2, 0: LOCATE 22, 1
  30.     PRINT "Press Alt-F for the file menu, or place the mouse ";
  31.     PRINT "over 'File' and click the left button"
  32.  
  33.     ShowM
  34.        
  35.     DO UNTIL i$ = CHR$(0) + CHR$(33): 'alt-F
  36.         i$ = INKEY$
  37.        
  38.         MButton LB%, RB%: GOSUB PrintButton
  39.         MLoc r%, c%
  40.         c% = c% / 8 + 1: r% = r% / 8 + 1
  41.         GOSUB PrintLocation
  42.         IF LB% AND r% = 1 AND c% < 20 THEN EXIT DO
  43.        
  44.     LOOP
  45.     'Erase the directions
  46.     Kolor 2, 0: Lokate 22, 1: Prnt CHR$(13): Prnt CHR$(10)
  47. '-----------------------------------------------------
  48. FileMenu:
  49.     Up$ = CHR$(0) + CHR$(72): Down$ = CHR$(0) + CHR$(80)
  50.     lft$ = CHR$(0) + CHR$(75): rght$ = CHR$(0) + CHR$(77)
  51.     Selection = 1
  52.     REDIM Msg$(1 TO 7)
  53.     Msg$(1) = " Load File"
  54.     Msg$(2) = " Save File"
  55.     Msg$(3) = " Merge File"
  56.     Msg$(4) = ""
  57.     Msg$(5) = " Print"
  58.     Msg$(6) = " Dos Shell"
  59. '--------------------------------------------------------------------------
  60.     'Save the screen under the menu
  61.     REDIM Temp%(500)
  62.     Kolor fore, back
  63.     Border 1
  64.     CALL HideM: SaveW VARSEG(Temp%(1)), 2, 10, 9, 24: ShowM
  65.  
  66. '--------------------------------------------------------------------------
  67. PrintMenu:
  68.     'wrap from top to bottom of the menu
  69.     IF Selection = 0 THEN Selection = 6
  70.     IF Selection = 7 THEN Selection = 1
  71.     IF Selection = 4 AND i$ = Up$ THEN Selection = 3
  72.     IF Selection = 4 AND i$ = Down$ THEN Selection = 5
  73.        
  74.     'print the menu
  75. HideM
  76.     Kolor fore, back
  77.     Border 1
  78.     OpenW 0, 2, 10, 9, 24
  79.     FillW 0, VARPTR(Msg$(1))
  80.  
  81.     'Highlight the hot key for each item
  82.     COLOR Bright, back
  83.     LOCATE 3, 12, 0: PRINT "L";
  84.     LOCATE 4, 12, 0: PRINT "S";
  85.     LOCATE 5, 12, 0: PRINT "M";
  86.     LOCATE 7, 12, 0: PRINT "P";
  87.     LOCATE 8, 12, 0: PRINT "D";
  88.  
  89.     'draw an extra line between the two areas
  90.     COLOR fore, back
  91.     LOCATE 6, 10, 0: PRINT "├─────────────┤"
  92.  
  93.  
  94.     'highlight the current selection
  95.     COLOR 11, 4
  96.     IF Selection = 1 THEN LOCATE 3, 11: PRINT " Load File  "
  97.     IF Selection = 2 THEN LOCATE 4, 11: PRINT " Save File  "
  98.     IF Selection = 3 THEN LOCATE 5, 11: PRINT " Merge File "
  99.     IF Selection = 5 THEN LOCATE 7, 11: PRINT " Print      "
  100.     IF Selection = 6 THEN LOCATE 8, 11: PRINT " Dos Shell  "
  101.  
  102.     'turn the mouse back on
  103. ShowM
  104.  
  105.     'wait until the mouse button is lifted
  106.     DO UNTIL NOT LB%: MButton LB%, RB%: GOSUB PrintButton: LOOP
  107. '--------------------------------------------------------------------------
  108. WaitFor:
  109.     i$ = INKEY$
  110.     IF i$ = Up$ THEN Selection = Selection - 1: GOTO PrintMenu
  111.     IF i$ = Down$ THEN Selection = Selection + 1: GOTO PrintMenu
  112.  
  113.     IF i$ = CHR$(13) GOTO Execute
  114.  
  115.     i$ = LCASE$(i$)
  116.     IF i$ = "l" THEN Selection = 1: GOTO Execute
  117.     IF i$ = "s" THEN Selection = 2: GOTO Execute
  118.     IF i$ = "m" THEN Selection = 3: GOTO Execute
  119.     IF i$ = "p" THEN Selection = 5: GOTO Execute
  120.     IF i$ = "d" THEN Selection = 6: GOTO Execute
  121.     IF i$ = CHR$(27) THEN Selection = 0: GOTO Execute
  122.  
  123.  
  124.     MButton LB%, RB%: GOSUB PrintButton
  125.  
  126.  
  127.     MLoc r%, c%
  128.     c% = c% / 8 + 1: r% = r% / 8 + 1
  129.     GOSUB PrintLocation
  130.  
  131.     IF NOT LB% GOTO WaitFor:  'Left button not down
  132.  
  133.     IF r% = 3 AND c% >= 10 AND c% <= 24 THEN Selection = 1: GOTO Execute
  134.     IF r% = 4 AND c% >= 10 AND c% <= 24 THEN Selection = 2: GOTO Execute
  135.     IF r% = 5 AND c% >= 10 AND c% <= 24 THEN Selection = 3: GOTO Execute
  136.     IF r% = 7 AND c% >= 10 AND c% <= 24 THEN Selection = 5: GOTO Execute
  137.     IF r% = 8 AND c% >= 10 AND c% <= 24 THEN Selection = 6: GOTO Execute
  138.        
  139.     'If L button down (not in the menu box) exit this menu
  140.     Selection = 0: GOTO Execute
  141.  
  142. '--------------------------------------------------------------------------
  143. Execute:
  144. HideM
  145.     CloseW VARSEG(Temp%(1)), 2, 10, 9, 24
  146.        
  147.     IF Selection = 1 THEN LOCATE 20, 20: PRINT "Loading File"
  148.     IF Selection = 2 THEN LOCATE 20, 20: PRINT "Saving File"
  149.     IF Selection = 3 THEN LOCATE 20, 20: PRINT "Merging File"
  150.     IF Selection = 5 THEN LOCATE 20, 20: PRINT "Printing "
  151.     IF Selection = 6 THEN LOCATE 20, 20: PRINT "Shell"
  152.        
  153.     IF Selection <> 0 THEN FOR n = 1 TO 2000: NEXT
  154.     COLOR 2, 0: LOCATE 20, 20: PRINT "                "
  155. ShowM
  156.     'wait until the mouse button is lifted
  157.     DO UNTIL NOT LB%: MButton LB%, RB%: GOSUB PrintButton: LOOP
  158.  
  159.     GOTO MainProgram
  160. '--------------------------------------------------------------------------
  161. PrintButton:
  162.     COLOR fore, back
  163.     LOCATE 1, 60: IF LB% THEN PRINT "L";  ELSE PRINT " ";
  164.     LOCATE 1, 62: IF RB% THEN PRINT "R";  ELSE PRINT " ";
  165.     RETURN
  166. PrintLocation:
  167.     COLOR fore, back
  168.     LOCATE 1, 64: PRINT r%; " ";
  169.     LOCATE 1, 68: PRINT c%; " ";
  170.     RETURN
  171.  
  172. '=====================================================================
  173. 'ShowM does not directly turn on the mouse cursor display.  It increments
  174. 'a counter (but only if the counter is < 0)  and when that counter is
  175. '0 the mouse is displayed.  HideM decrements the counter.
  176. 'This counter is part of the device driver.  InitM sets it to -1 and
  177. 'positions the cursor at the middle of the screen.
  178.  
  179. 'The cursor seems to be turned off when you stop to use the Qbasic editor.
  180.  
  181. 'Hide the cursor when saving a window or printing anything.  When it is
  182. 'moved it will restore what used to be there.
  183.  
  184. 'This doesn't work with MouseCtl.Com (from PC Magazine)
  185.  
  186.