home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MOUSE / MSMOUSE1.ZIP / BAS.ZIP / BATEST.BAS < prev    next >
Encoding:
BASIC Source File  |  1989-02-10  |  3.4 KB  |  105 lines

  1. 100 '***********************************************************
  2. 110 '*  BATEST.BAS                                             *
  3. 120 '*                                                         *
  4. 130 '*  Demonstrates use of the Microsoft Mouse from BASICA    *
  5. 140 '***********************************************************
  6. 150 '
  7. 160 ' Clear the display
  8. 170  CLS
  9. 180 '
  10. 190 ' Determine mouse interrupt address
  11. 200  DEF SEG = 0
  12. 210  MOUSEG = 256 * PEEK(207) + PEEK(206)
  13. 220  MOUSE = 256 * PEEK(205) + PEEK(204) + 2
  14. 230  DEF SEG = MOUSEG
  15. 232  IF (MOUSEG OR (MOUSE - 2)) AND PEEK(MOUSE - 2) <> 207 THEN GOTO 260
  16. 234 PRINT "Mouse driver not found" : END
  17. 240 '
  18. 250 ' Display instructions for user
  19. 260  PRINT "BATEST - Mouse demonstration using interpreted BASIC"
  20. 270  PRINT
  21. 280  PRINT "Use mouse to highlight a menu item."
  22. 290  PRINT "Press either button to make selection. "
  23. 300 '
  24. 310 ' Reset mouse, and verify it's existence
  25. 320  M1%= 0
  26. 330  CALL MOUSE(M1%, M2%, M3%, M4%)
  27. 340 '
  28. 350 ' Quit if mouse wasn't found
  29. 360  IF M1%= 0 THEN PRINT "Error: Mouse not found ": END
  30. 370 '
  31. 380 ' Initialize menu pointer to first choice
  32. 390  MENUPTR% = 1
  33. 400 '
  34. 410 ' Initialize count of accumulated vertical mouse motion
  35. 420  MOTION% = 0
  36. 430 '
  37. 440 ' Set flag to cause the menu to be updated first time through
  38. 450  WFLAG% = 1
  39. 460 '
  40. 470 ' Main loop starts here
  41. 480  WHILE 1
  42. 490    '
  43. 500    ' Update the menu only when necessary
  44. 510     WHILE WFLAG% = 1
  45. 520        WFLAG% = 0
  46. 530       '
  47. 540       ' Print first line of the menu, highlighted if selected
  48. 550        IF MENUPTR% = 1 THEN COLOR 0,7 ELSE COLOR 7,0
  49. 560        LOCATE 10, 29
  50. 570        PRINT " 1. First menu choice "
  51. 580       '
  52. 590       ' Print second line of the menu, highlighted if selected
  53. 600        IF MENUPTR% = 2 THEN COLOR 0,7 ELSE COLOR 7,0
  54. 610        LOCATE 11, 29
  55. 620        PRINT " 2. Second choice     "
  56. 630       '
  57. 640       ' Print third line of the menu, highlighted if selected
  58. 650        IF MENUPTR% = 3 THEN COLOR 0,7 ELSE COLOR 7,0
  59. 660        LOCATE 12, 29
  60. 670        PRINT " 3. Third choice      "
  61. 680       '
  62. 690       ' Make sure highlighting isn't left on
  63. 700        COLOR 7, 0
  64. 710       '
  65. 720       ' End of the menu updating
  66. 730     WEND
  67. 740    '
  68. 750    ' Accumulate vertical mouse motion counts
  69. 760     M1%= 11
  70. 770     CALL MOUSE(M1%, M2%, M3%, M4%)
  71. 780     MOTION% = MOTION% + M4%
  72. 790    '
  73. 800    ' Move up the menu if enough mouse motion
  74. 810     IF MOTION% > -17 THEN GOTO 880
  75. 820        MOTION% = 0
  76. 830        IF MENUPTR% <= 1 THEN GOTO 880
  77. 840           MENUPTR% = MENUPTR% - 1
  78. 850           WFLAG%= 1
  79. 860    '
  80. 870    ' Move down the menu if enough mouse motion
  81. 880     IF MOTION% < 17 THEN GOTO 950
  82. 890        MOTION% = 0
  83. 900        IF MENUPTR% >= 3 THEN GOTO 950
  84. 910           MENUPTR% = MENUPTR% + 1
  85. 920           WFLAG% = 1
  86. 930    '
  87. 940    ' Check if left button has been pressed
  88. 950     M1%= 5
  89. 960     M2%= 0
  90. 970     CALL MOUSE(M1%, M2%, M3%, M4%)
  91. 980     IF M2% = 0 THEN GOTO 1030
  92. 990        PRINT "Left button was used to select choice", MENUPTR%
  93. 1000       END
  94. 1010   '
  95. 1020   ' Check if right button has been pressed
  96. 1030    M1%= 5
  97. 1040    M2%= 1
  98. 1050    CALL MOUSE(M1%, M2%, M3%, M4%)
  99. 1060    IF M2% = 0 THEN GOTO 1110
  100. 1070       PRINT "Right button was used to select choice", MENUPTR%
  101. 1080       END
  102. 1090   '
  103. 1100   ' Loop back until one of the buttons gets pressed
  104. 1110 WEND
  105.