For example t = 0.5; Do[t = Module[{a = t}, c = (a^2 - 2)/3;Pause[1]; err = c - a; c];
Print[err], {i, 100}]
I want to see the err
in every interation step while the code is running. But I don't want to see the err
in my code notebook.Is there anyway to show it elsewhere? (in a new notebook or bottom border?)
1 Answer
Messages Window
You can use this printMsg
function, replacing Print
in your code:
printMsg[x__] :=
NotebookWrite[
Notebooks["Messages"][[1]],
Cell[RawBoxes @ ToBoxes @ Row @ {x}, "Text"]
]
This should print to the Messages window, which you may need to open.
Window Status Area
To print to the StatusArea of the evaluation notebook use this in place of Print
:
printStatus[x__] :=
(CurrentValue[EvaluationNotebook[], WindowStatusArea] = ToString @ Row @ {x};)
Reference: How to briefly display message in status area?
Monitor
If you only want to see one value rather than a list of values you can use Monitor
, though this does display within the Notebook.
x = 0;
Monitor[
Do[x++; Pause[1], {50}],
x
]
See also: Interrogating a running evaluation
showStatus
function from mathematica.stackexchange.com/questions/26438 $\endgroup$