home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MOUSE / MSMOUSE1.ZIP / BAS.ZIP / QBTEST.BAS < prev    next >
Encoding:
BASIC Source File  |  1988-12-30  |  3.4 KB  |  127 lines

  1.   '*******************************************************************
  2.   '*  QBTEST.BAS                                                     *
  3.   '*                                                                 *
  4.   '*  Demonstrates three-line menu using QuickBASIC                  *
  5.   '*                                                                 *
  6.   '*  To load QBMOUSE.QLB into memory with QuickBASIC:               *
  7.   '*  QB /L QB.QLB                                                   *
  8.   '*******************************************************************
  9.  
  10.     DEFINT A-Z
  11.     DECLARE SUB Mouse (m0%, M1%, M2%, M3%)
  12.  
  13.   ' Clear the display
  14.     CLS
  15.  
  16.   ' Display simple instructions for user
  17.     PRINT "QBTEST - Mouse demonstration using QuickBASIC 4.5"
  18.     PRINT
  19.     PRINT "Use mouse to highlight a menu option."
  20.     PRINT "Press either button to select option. "
  21.  
  22.   ' Check for mouse, resetting it in the process
  23.     M1 = 0
  24.     Mouse M1, M2, M3, M4
  25.  
  26.   ' Quit if mouse wasn't found
  27.     IF M1 = 0 THEN
  28.         PRINT "Error: Mouse not found "
  29.         SYSTEM
  30.     END IF
  31.  
  32.   ' Initialize menu pointer to first option
  33.     menuPtr = 1
  34.  
  35.   ' Initialize count of accumulated vertical mouse motion
  36.     motion = 0
  37.  
  38.   ' Set flag to update menu first time
  39.     wFlag = 1
  40.  
  41.   ' Main loop starts here
  42.     DO
  43.  
  44.       ' Update the menu only when necessary
  45.         IF wFlag = 1 THEN
  46.             wFlag = 0
  47.  
  48.           ' Print first line of the menu, highlighted if selected
  49.             IF menuPtr = 1 THEN
  50.                 COLOR 0, 7
  51.             ELSE
  52.                 COLOR 7, 0
  53.             END IF
  54.             LOCATE 10, 29
  55.             PRINT " 1. First menu option "
  56.  
  57.           ' Print second line of the menu, highlighted if selected
  58.             IF menuPtr = 2 THEN
  59.                 COLOR 0, 7
  60.             ELSE
  61.                 COLOR 7, 0
  62.             END IF
  63.             LOCATE 11, 29
  64.             PRINT " 2. Second option     "
  65.  
  66.           ' Print third line of the menu, highlighted if selected
  67.             IF menuPtr = 3 THEN
  68.                 COLOR 0, 7
  69.             ELSE
  70.                 COLOR 7, 0
  71.             END IF
  72.             LOCATE 12, 29
  73.             PRINT " 3. Third option      "
  74.  
  75.           ' Be sure highlighting is turned off
  76.             COLOR 7, 0
  77.  
  78.           ' End of the menu updating
  79.         END IF
  80.  
  81.       ' Accumulate vertical mouse motion counts
  82.         M1 = 11
  83.         Mouse M1, M2, M3, M4
  84.         motion = motion + M4
  85.  
  86.       ' Move up the menu if enough mouse motion
  87.         IF motion < -17 THEN
  88.             motion = 0
  89.             IF menuPtr > 1 THEN
  90.                 menuPtr = menuPtr - 1
  91.                 wFlag = 1
  92.             END IF
  93.         END IF
  94.  
  95.       ' Move down the menu if enough mouse motion
  96.         IF motion > 17 THEN
  97.             motion = 0
  98.             IF menuPtr < 3 THEN
  99.                 menuPtr = menuPtr + 1
  100.                 wFlag = 1
  101.             END IF
  102.         END IF
  103.  
  104.       ' Check if left button pressed
  105.         M1 = 5
  106.         M2 = 0
  107.         Mouse M1, M2, M3, M4
  108.         IF M2 <> 0 THEN
  109.             PRINT "Left button used to select option", menuPtr
  110.             SYSTEM
  111.         END IF
  112.  
  113.       ' Check if right button pressed
  114.         M1 = 5
  115.         M2 = 1
  116.         Mouse M1, M2, M3, M4
  117.         IF M2 <> 0 THEN
  118.             PRINT "Right button used to select option", menuPtr
  119.             SYSTEM
  120.         END IF
  121.  
  122.       ' Loop back until one of the buttons is pressed
  123.     LOOP
  124.  
  125.   ' All done
  126.     END
  127.