# How to switch off all messages?

How can I want to switch off all messages in a Mathematica session? Quiet[expr] allows me to evaluate expr without messages. Off[msg] switches off the particular message msg.

Is there a command that, once evaluated, guarantees that all further evaluations will run quietly? (Unless some messages are turned back On)

-
It is not clear why Quiet isn;t what you are looking for. Do you mean that you want the first message displayed but then no others? Can you please clarify. – Mike Honeychurch Nov 19 '13 at 20:40
Why do you want to turn off all messages? Perhaps what you want is not to turn them off, just to prevent them from being printed (which is technically not the same thing). Try $Messages = {}. – Szabolcs Nov 19 '13 at 20:46 @MikeHoneychurch I don't want any messages. I want a command that sets the Kernel in a state such that further evaluations won't output messages. – becko Nov 19 '13 at 21:53 @Szabolcs What's the difference between turning messages off and prevent them from being printed? – becko Nov 19 '13 at 21:53 @becko ok. in that case suggestions made in the answer and comments should help you – Mike Honeychurch Nov 19 '13 at 22:01 ## 2 Answers First, note that turning off messages is technically not the same thing as not printing them. You can avoid printing messages by removing the output channel they're being sent to: $Messages = {}


Restore the previous behaviour using $Messages =$Output, provided that you haven't changed $Output. But this won't turn messages off, it will only avoid printing them. Here's the transcript for one particular example which shows the effect of turning off messages, as opposed to not printing them: In[1]:= boo::mess = "Boo message" Out[1]= "Boo message" In[2]:= boo[] := (Message[boo::mess]; 1) In[3]:= boo[] During evaluation of In[3]:= boo::mess: Boo message Out[3]= 1 In[4]:= Check[boo[], "error"] During evaluation of In[4]:= boo::mess: Boo message Out[4]= "error" In[5]:= Off[boo::mess] In[6]:= Check[boo[], "error"] Out[6]= 1 In[7]:= On[boo::mess]$Messages = {};

In[9]:= Check[boo[], "error"]
Out[9]= "error"


(Make sure that you evaluate these as separate inputs (cells). Some only have an effect on subsequent inputs, but not on separate code within the same input.)

Notice that turning off the message had an effect on Check, but simply preventing printing it did not. It has effects on various other documented and undocumented parts of Mathematica as well, such as the debugging tools ("Break on messages" feature).

Quiet[expr] does actually prevent the messages generated by expr from reaching any code outside of the Quiet[...], just like turning Off the messages.

Here's a different idea: if your program is written in a script (.m file), then you can run it on a single input line using Get. This means that you can capture all generated messages with $MessageList. Then you can create a message group for them which will allow you to easily toggle them using Off and On. If a new, unexpected message shows up at some point, it will still get printed, which might be good or bad depending on your application. - +1 Actually, a script is precisely what I have in mind. It would be nice if I could turn all messages off, not just a group. Btw, how do I create a message group (by the [] it seems you wanted to include a link or something)? And couldn't I create a message group including all messages? – becko Nov 20 '13 at 14:08 It seems you were trying to include a link. I tried to edit your post to fix it, but it didn't work... I think the $s are messing up the links. – becko Jan 14 '14 at 21:44
@becko Thanks for noticing the problem. I'll fix it. I rejected your edit the first time because it showed wrong in the diff view (possibly because of the dollar sign again), then because I was in the process of trying to fix it. There are problems with dollar signs sometimes :-( – Szabolcs Jan 14 '14 at 21:51
Ok. I did one last edit. I leave in your hands. – becko Jan 14 '14 at 21:54
@becko I think I managed to fix it now ... – Szabolcs Jan 14 '14 at 21:59

You can add Quiet to all evaluated expressions by

\$Pre = Quiet


1/0


No messages

-