SOUND Truncation End of Compiled Program, OK Interpreter (32419)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0

This article was previously published under Q32419

SUMMARY

A sound created with the SOUND statement is placed in a queue and execution continues with the next statements while the sound is played. Sounds created with the SOUND statement are not heard if the compiled program ends before the sound can be played. This does not happen with programs in the QuickBASIC interpreter since the QuickBASIC interpreter is still available to make the sound after the program ends. If SOUND statements are put at the end of a program, you should create a delay in compiled programs so that the sound finishes before termination. This information applies to most Microsoft BASIC compilers.

MORE INFORMATION

The following line of code produces a sound that lasts for three seconds in the interpreter; however, no sound is heard when it is compiled:
   SOUND 523, 54
				
The following program creates a four-second delay using the ON TIMER statement so that the compiled program will continue to execute and the sound will be heard:
      SOUND 523, 54
      IF SYSTEM(4)=0 THEN
      GOTO FINISH               ' SYSTEM(4)=0 means program is interpreted
      ELSEIF SYSTEM(4)=1 THEN
      TIMER ON                  ' SYSTEM(4)=1 means program is compiled
      ON TIMER (4) GOSUB finish
      top: GOTO top
      END IF
      finish:
      END
				

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:KB32419