QBasic 1.1: ON PLAY Statement
Explanation
PLAY, ON PLAY Statements (Event Trapping)
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.
Worth knowing
Useful and cross-version information about the programming environments of QBasic, QuickBasic and Visual Basic for DOS.
Syntax
PLAY ON |
PLAY OFF |
PLAY STOP |
ON PLAY(queuelimit%) GOSUB line |
Description / Parameter(s)
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