Re: Must Play[] generate a graphic?

*To*: mathgroup at smc.vnet.net*Subject*: [mg16008] Re: Must Play[] generate a graphic?*From*: Paul Abbott <paul at physics.uwa.edu.au>*Date*: Sat, 20 Feb 1999 02:52:02 -0500*Organization*: University of Western Australia*References*: <7ag320$aia@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Ron Griffin wrote: > When I use Play[] to generate a sound, I always get an accompanying > graphic. Because I'm using Play merely to alert me regarding my program's > progress during a long looping procedure, the graphic has no value. > Inspection of the grand Mathematica book provided me with no help. Ideas? Two suggestions: [1] Why not use the built-in Message mechanism to keep you updated? See the Mathematica book: Section 2.8.21 or use the following button to go to the on-line documentation: Cell[TextData[{ "See the ", StyleBox["Mathematica", FontSlant->"Italic"], " book: ", ButtonBox["Section 2.8.21", ButtonData:>{"2.8.21", "21.29"}, ButtonStyle->"MainBookLink"], "." }], "Text"] If you look up Warning under the Option Inspector you will see that the default behavior for "WarningAction" is to "Beep". You can use this feature to alert you to the progress of your loop. If you add a message, say Progress::update = "Now at iteration `1`."; and then, from your loop call the message, (where i is the loop index), Message[Progress::update, i] a message will be printed out and you will also get a beep. [2] An alternative approach is to use the status bar. The following short Notebook is to appear in the forthcoming issue of the Mathematica Journal: Notebook[{ Cell[CellGroupData[{ Cell["SetNotebookStatusLine", "Section"], Cell[TextData[{ "Theodore Gray (", ButtonBox["theodore at wolfram.com", ButtonData:>{ URL[ "mailto:theodore at wolfram.com"], None}, ButtonStyle->"Hyperlink"], ") writes: I find the ", Cell[BoxData[ FormBox[ StyleBox["SetNotebookStatusLine", "Input"], TraditionalForm]]], " packet a useful way to monitor progress. For example, to indicate the \ state of progress of your calculation," }], "Text", CellTags->{ "Theodore Gray", "SetNotebookStatusLine", "monitoring progress"}], Cell[BoxData[ \(TraditionalForm \`ShowStatus(status_) := LinkWrite($ParentLink, SetNotebookStatusLine(FrontEnd`EvaluationNotebook(), ToString(status)))\)], "InputOnly"], Cell[TextData[{ "displays the current value of ", Cell[BoxData[ FormBox[ StyleBox["status", "InlineInput"], TraditionalForm]]], " in the status area (bottom left-hand corner of the Notebook). It's a lot \ faster than ", Cell[BoxData[ FormBox[ StyleBox["Print", "Input"], TraditionalForm]]], ", and it doesn't mess up your notebook with spurious output. As long as \ you're not sending more than a few packets per second it should not \ significantly effect the speed of your calculation. Here is a simple \ example:" }], "Text", CellTags->{"status area", "Print"}], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{\(If[Mod[i, 10] == 0, ShowStatus[i]]\), ";", RowBox[{"{", RowBox[{"i", ",", TagBox[ RowBox[{"\[Zeta]", "(", TagBox["i", (Editable -> True)], ")"}], InterpretTemplate[ Zeta[ #]&]]}], "}"}]}], ",", \({i, 500}\)}], "]"}], ";"}], TraditionalForm]], "InputOnly"], Cell[TextData[{ "The ", Cell[BoxData[ FormBox[ StyleBox[\(If[]\), "Input"], TraditionalForm]]], " test causes the status to be set only every tenth time through the loop, \ avoiding wasting time updating the status too frequently. You may wish to \ adjust this parameter depending on the calculation and the speed of your \ computer." }], "Text", CellTags->"If"] }, Open ]] } ] Cheers, Paul ____________________________________________________________________ Paul Abbott Phone: +61-8-9380-2734 Department of Physics Fax: +61-8-9380-1014 The University of Western Australia Nedlands WA 6907 mailto:paul at physics.uwa.edu.au AUSTRALIA http://www.physics.uwa.edu.au/~paul God IS a weakly left-handed dice player ____________________________________________________________________