Volume 9, Issue 2
Tricks of the Trade
In and Out
Download This Issue
In and Out
Q: How can I play a sound to alert me regarding my program's progress during a long looping procedure?
A: You can use the built-in Message mechanism. You can specify the required (default) behavior of Message by setting WarningAction to include Beep as follows:
1. Open the Option Inspector by clicking Format Option Inspector. Make sure the scope is global.
2. Locate WarningAction by typing in "warning" in the Lookup text field.
3. Modify WarningAction to include Beep.
Add a message displaying the iteration number (see Section 2.9.21 of The Mathematica Book).
Redundant or repetitive messages are, by default, suppressed in long calculations; therefore, you should turn off General::stop (see General::stop in the Reference Guide).
From your loop, call this message.
Alternatively, if you have suitable text-to-speech system software installed on your system, you can ask the front end to "speak" the given text, which should be a text string.
To set the speaking voice, use FrontEndExecute[SetSpeechParametersPacket[i]] where i is a number between 1 and the number of voices you have installed. (For further information, see the following The Mathematica Journal articles: "Tricks of the Trade" (SetNotebookStatusLine), 7 (3), 1999 p. 263, and "In and Out" (Why the Beep?), 8 (3), 2002 p. 400.)
About Mathematica | Download Mathematica Player
Copyright © 2004 Wolfram Media, Inc. All rights reserved.