qbasic.hlp (Topic list)
PLAY, ON PLAY Statements (Event Trapping)
  Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
PLAY enables, disables, or suspends play event trapping.
If event trapping is enabled, ON PLAY branches to a subroutine whenever
the music buffer contains fewer than a specified number of notes.
 
PLAY ON
PLAY OFF
PLAY STOP
ON PLAY(queuelimit%) GOSUB line
 
    ■ PLAY ON        Enables play event trapping.
    ■ PLAY OFF       Disables play event trapping.
    ■ PLAY STOP      Suspends play event trapping. Events are processed once
                     event trapping is enabled by PLAY ON.
    ■ queuelimit%    A number in the range 1 through 32. ON PLAY branches to
                     a subroutine when there are fewer than queuelimit%
                     notes in the music buffer.
    ■ line           The label or number of the first line of the
                     event-trapping subroutine.
 
Example:
    ON PLAY(3) GOSUB Background
    PLAY ON
    Music$ = "MBo3L8ED+ED+Eo2Bo3DCL2o2A"
    PLAY Music$
    LOCATE 2, 1: PRINT "Press any key to stop.";
    DO WHILE INKEY$ = "": LOOP
    END
 
    Background:
        i% = i% + 1
        LOCATE 1, 1: PRINT "Background called "; i%; "time(s)";
        PLAY Music$
        RETURN
 
See Also    PLAY (Music)    PLAY Function