0
$\begingroup$

I've been redirecting outputs to a separate notebook using this simple code to modify the $Post variable:

nbout = CreateDocument[]

$Post = Function[expr, SelectionMove[nbout, Next, Cell];
   NotebookWrite[nbout, Cell[BoxData@ToBoxes@expr, "Output"]]];

This works nicely except for code that does normally not generate output, i.e. lines with ";". For those lines, a Null output is generated in the nbout notebook.

Is there a simple way to suppress this output?

Many thanks in advance for any advice.

$\endgroup$
3
  • 1
    $\begingroup$ You can write: If[expr === Null, ...]. $\endgroup$ Jun 8, 2022 at 8:50
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Jun 8, 2022 at 15:56
  • $\begingroup$ Thank you ! This works. $\endgroup$
    – Jan
    Jun 8, 2022 at 18:10

0

Your Answer

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

Browse other questions tagged or ask your own question.