◄QuickSCREEN► ◄Details► ◄Example► ◄Contents► ◄Index► ────────────────────────────────────────────────────────────────────────────── ON PLAY(n) Statement Programming Example Here is a program that plays continuous music by calling an event-handling subroutine when the music buffer goes from three to two notes: ' Call subroutine Background when the music buffer goes from ' 3 to 2 notes. ON PLAY(3) GOSUB Background ' Turn on event trapping for PLAY. PLAY ON ' Define a string containing the melody. Lizzie$ = "o3 L8 E D+ E D+ E o2 B o3 D C L2 o2 A" ' Play the melody for the first time. PLAY "MB X" + VARPTR$(Lizzie$) ' Continue until a key is pressed. LOCATE 2, 1 : PRINT "Press any key to stop."; DO WHILE INKEY$ = "" LOOP END ' PLAY event-handling subroutine. Background: ' Increment and print a counter each time. Count% = Count% + 1 LOCATE 1, 1 : PRINT "Background called "; Count%; "time(s)"; ' Execute another PLAY to fill the buffer. PLAY "MB X" + VARPTR$(Lizzie$) RETURN