8
$\begingroup$

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

$\endgroup$
0

2 Answers 2

12
$\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$
1
  • $\begingroup$ Thank you very much indeed ! $\endgroup$
    – MiuraB
    Jul 19, 2019 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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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