I want to print a dynamic output while some code is running and then automatically delete it when when the output is done. PrintTemporary is not quite what I am looking for -- I want the output to be deleted from inside the module rather than when the cell is done evaluating because I want to evaluate several modules in the same cell. Here is an example of what I am looking for:

    Print["% Complete: ",Dynamic[n*100/steps]];
        (*CODE RUNS*)
    (*Delete Output Cell*)

I want to explicitly delete the output cell created when running test, but cannot find the commands to do so. All I have seen on stackexchange is how to delete ALL output cells or how to print temporarily, which I do not want.


1 Answer 1


Perhaps something like:

test[steps_] := Module[{}, n = 0;
  Print["% Complete: ", Dynamic[n*100/steps]];
  For[n = 0, n < steps, n++, Pause[1]];
  NotebookFind[SelectedNotebook[], "Print", All, CellStyle]; 

enter image description here

See also: A self-deleting button to delete Print cells


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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