How can I capture output from Print from a function which does not leave the printed object as its final output, (and which I do not wish to edit)? E.g.
Module[{},
Print[Plot[Sin[x], {x, 0, 2 Pi}]];
a = 123]
I would like to use something like a temporary setting for $PrePrint or $Post, rather than use cell selection (SelectionMove, NotebookRead).
The aim is somehow to intercept the Print output -- the plot object -- and set it to a variable, (without altering the module).
This attempt did not work:-


Print[Sow@Plot[Sin[x], {x, 0, 2 Pi}]]and// Reapat the end captures Print output? – BoLe Apr 03 '13 at 11:00123being stored, the plot, or both? – Dr. belisarius Apr 03 '13 at 11:14Printcommand. – Chris Degnen Apr 03 '13 at 12:11$PrePrintor$Postwhich would also capture the output ofPlot[Sin[x],{x,-5,5}];? – acl Apr 03 '13 at 12:32$Output. But setting a variable with$PrePrintcould be neater. – Chris Degnen Apr 03 '13 at 12:56CellPrint[]instead? – J. M.'s missing motivation Apr 03 '13 at 14:28CellPrintcould be used. But the idea is not to alter the module. – Chris Degnen Apr 03 '13 at 15:05