Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Check[] *and* Off[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21906] Re: Check[] *and* Off[]
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 4 Feb 2000 02:54:39 -0500 (EST)
  • References: <87b0dq$o3v@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Paul,
How about Carl Wolls function SilentCheck? - I quote from his posting

SilentCheck::usage =
"SilentCheck[expr,failexpr] evaluates expr; if no messages are generated
it gives the result, otherwise it gives failexpr.
";

SilentCheck is useful here, since if the compiled program fails to find any
runs of the
right length, it will produce an error. Normally, once the error occurs, the
uncompiled
version will be applied. In this case that is totally unnecessary, since if
the compiled
program fails to find any runs we are done. With SilentCheck, the uncompiled
version is
never run. The timings of the various versions (defined in my previous post)
were as
follows:


SilentCheck[expr_, err_] :=
  Module[{ans, flag},
  Unprotect[Message];
  _Message := Throw[flag, SilentCheck];
  ans = Catch[expr, SilentCheck];
  Clear[Message];
  Protect[Message];
  If[ans === flag, err, ans]
]


Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565



"Paul Howland" <paul.howland at nc3a.nato.int> wrote in message
news:87b0dq$o3v at smc.vnet.net...
> Thanks for all those who responded to my previous question.  Now a new,
> unrelated one.
>
> I have a function which uses the FindRoot function.  Occasionally
> FindRoot fails to converge, as there really is no solution.  To trap
> this occurence, I have wrapped the call to FindRoot in the Check[]
> function.  If an error in FindRoot occurs, I trap it, and substitute a
> Null solution into the list I am generating.  Everything works
> beautifully so far.  However, I don't want Mathematica to print error
> messages all over my screen every time this occurs!!  I'm dealing with
> the problem!!  However, the manual says that Check[] will not trap
> errors that have been disabled with Off[].  So, it seems there is no way
> to silently trap an error message.  Is this true?
>
> Paul.
>
>



  • Prev by Date: Re: Creating Raster Image Animation
  • Next by Date: Re: Re: PlotVectorField
  • Previous by thread: RE: Re: Check[] *and* Off[]
  • Next by thread: Re: Check[] *and* Off[]