MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Abort computation on any message


On 12/02/2012 09:59, David Bailey wrote:
> Unprotect[Message];
> pass = False;
> Message[mes_MessageName, args___] :=
>     Block[{pass = True}, Message[mes, args];
>       Abort[]] /; (Head[mes] === MessageName&&  ! pass);
> Protect[Message];

I discovered after posting this that this version will abort inside 
Quiet - here is a better version:


Unprotect[Message];
pass = False;
Message[mes_MessageName, args___] :=
    Block[{pass = True}, Message[mes, args];
      Abort[]] /; (Head[mes] === MessageName && ! pass);
Protect[Message];
Unprotect[Quiet];
Quiet[x___]:=Block[{pass=True},Quiet[x]]/;(!pass);
Protect[Quiet];

David Bailey
http://www.dbaileyconsultancy.co.uk



  • Prev by Date: Re: Setting global graphics options
  • Next by Date: Re: Setting global graphics options
  • Previous by thread: Re: Abort computation on any message
  • Next by thread: Run external programs in parallel on OSX