RE: Re: Check[] *and* Off[]
- To: mathgroup at smc.vnet.net
- Subject: [mg21915] RE: [mg21894] Re: Check[] *and* Off[]
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Fri, 4 Feb 2000 02:54:44 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Paul Howland wrote: ------------------------------- Well... before anyone wastes their breath trying to answer my question about whether it is possibly to "silently" trap an error message using Check[], I have found the way to do it. And it is trivial. All you need do is temporarily redefine the messages channel. So, the answer is, do this: messagechan=$Messages; $Messages={}; Check[myfunction[], myerrfunction[]]; $Messages=messagechan; -------------------- Block is designed for this sort of thing. So the following does the same thing as your solution. Block[ {$Messages={}}, Check[myfunction, myerrfunction[] ] ] Look up Block at my website for more applications of Block. -------------------- Regards, Ted Ersek On 12-18-99 Mathematica tips, tricks at http://www.dot.net.au/~elisha/ersek/Tricks.html had a major update -----Original Message----- From: Paul Howland To: mathgroup at smc.vnet.net paul.howland at nc3a.nato.int Subject: [mg21915] [mg21894] Re: Check[] *and* Off[] Well... before anyone wastes their breath trying to answer my question about whether it is possibly to "silently" trap an error message using Check[], I have found the way to do it. And it is trivial. All you need do is temporarily redefine the messages channel. So, the answer is, do this: messagechan=$Messages; $Messages={}; Check[myfunction[], myerrfunction[]]; $Messages=messagechan; and the screen no longer fills up with unwanted error messages. The only slight disadvantage of this approach is that *all* error messages are lost, so if you are trying to Check[] for specific messages only, then you won't see the messages you're not trapping. I guess in this situation you might want to re-direct $Messages to a file instead. Paul