home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / QBNWS103.ZIP / UEVENT.ZIP / CHNEVENT.BAS next >
Encoding:
BASIC Source File  |  1990-03-06  |  1.4 KB  |  45 lines

  1. ' *********** CHNEVENT.BAS *******************************************
  2.  
  3.       DEFINT A-Z
  4.  
  5.       DECLARE FUNCTION InstallHandler% (BYVAL InterruptNumber%)
  6.  
  7. ' This MASM function attempts to install our service routine,
  8. ' returning -1 if it could not do so (zero if OK).  The parameter
  9. ' InterruptNumber can range from 0-255, but for the sake of your
  10. ' sanity, please don't try it indiscriminately... there *are* some
  11. ' vectors which will cause crashes (at a minimum).
  12. '
  13. ' Contrast this with the InstallHandler in the HDWEVENT package, which
  14. ' is passed an IRQ number from 2-7, not a vector number from 0 to 255.
  15. '
  16. ' NOTE that this CANNOT be called multiple times to install multiple
  17. ' handlers!
  18.  
  19.       ON UEVENT GOSUB MyEventHandler   'establish a handler
  20.       UEVENT ON                        'activate handler
  21.  
  22.       IF InstallHandler(9) THEN
  23.          PRINT "Could not install interrupt handler"
  24.          STOP
  25.       END IF
  26.  
  27. ' The following is just a way to get INT 9's to occur.  Whatever you
  28. ' type will be echoed onto the screen, and each press, release, or
  29. ' repeat of a key will invoke MyEventHandler, causing a click sound.
  30.  
  31.       DO
  32.          k$ = INKEY$
  33.          IF k$ = CHR$(27) THEN
  34.            EXIT DO
  35.          END IF
  36.          PRINT k$;
  37.       LOOP
  38.       SYSTEM
  39.  
  40. MyEventHandler: 'just make a ticking noise when the event is detected
  41.  
  42.       SOUND 2000, .1    'make a small noise
  43.       RETURN
  44.  
  45.