8
$\begingroup$

By evaluating some Mathematica commands, I wish to get the equivalent effect as selecting Delete All Messages on the message window.

$\endgroup$
10
$\begingroup$

You can obtain the NotebookObject corresponding to the messages window using MessagesNotebook, and then delete all the cells using NotebookDelete:

NotebookDelete @ Cells @ MessagesNotebook[]
$\endgroup$
  • $\begingroup$ Thank you very much indeed ! $\endgroup$ – MiuraB Jul 19 at 6:21
11
$\begingroup$

You can also do what the button in messages notebook does:

FrontEndExecute[
  { 
    FrontEndToken[FrontEnd`MessagesNotebook[], "SelectAll"], 
    FrontEndToken[FrontEnd`MessagesNotebook[], "Clear"]
  }
]

The advantage is that it may not require kernel to run at all because all symbols are known by the front end. So this will work:

Button["test", (*our code*), Evaluator -> None ]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.