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 errin 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?)
Asked
Active
Viewed 44 times
1
XinBae
- 617
- 3
- 9
1 Answers
1
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
Mr.Wizard
- 271,378
- 34
- 587
- 1,371
showStatusfunction from https://mathematica.stackexchange.com/questions/26438 – SPPearce Jul 25 '18 at 09:05