Re: Stop on message?
- To: mathgroup at smc.vnet.net
- Subject: [mg126769] Re: Stop on message?
- From: Ralph Dratman <ralph.dratman at gmail.com>
- Date: Wed, 6 Jun 2012 04:52:54 -0400 (EDT)
- Delivered-to: email@example.com
- References: <201205260911.FAA07083@smc.vnet.net>
Re: the recent "stop on message" discussion. The earlier-posted solution from StackExchange suggests adding the following to the top of a notebook: - - - - - - - - - - messageHandler = If[Last[#], Abort] & Internal`AddHandler["Message", messageHandler] (* The above will abort the computation whenever a message would be printed= . *) (* It can be turned off using*) (* Internal`RemoveHandler["Message", messageHandler] *) - - - - - - - - - - This helps, and seems to prevent a complete freeze, but it does not always terminate the evaluation immediately. The Abort call seems to wait for something to finish before stopping everything. >From prior experience, I knew that Interrupt works more quickly than Abort. I realize this seems a little bit illogical, but nevertheless, that is my observation: Interrupt gets you out of trouble instantly, while Abort often doesn't. I substituted Interrupt in the handler, with much better results, as follow= s: - - - - - - - - - - (* ----- proposed new version ----- *) messageHandler = If[Last[#], Interrupt] & Internal`AddHandler["Message", messageHandler] (* The above will immediately (!) put up an Abort dialog offering to *) (* end the evaluation whenever an enabled message is issued. *) (* It can be turned off using *) (* Internal`RemoveHandler["Message", messageHandler] *) - - - - - - - - - - This tiny enhancement to Mathematica has proved amazingly helpful, and I hope everyone will try it. It is a relief not to be always anticipating the next messy crash. Let me know if you have any additions or corrections. Ralph Dratman On Tue, May 29, 2012 at 5:47 AM, Szabolcs Horv=E1t <szhorvat at gmail.com> wro= te: > Please see here for a method that will reliably abort immediately when a > message is generated. > http://mathematica.stackexchange.com/questions/1512/how-to-abort-on-any-m= essage-generated
- Re: Stop on message?
- From: Christoph Lhotka <firstname.lastname@example.org>
- Re: Stop on message?