I would like to use Dynamic[] to print progress of evaluation of some function, which works quite long. let's say that the definition of F[x] is such as given below:

F[x_]:=Block[{some variables},
      Print["progress: ",Dynamic[progress],"%"];
      (* some code here *)

Then I would like to use this function in for loop:

    (* do sth with u *)

Problem is that, after first step of for loop in another step is also printed progress of F, but the first one is also changed. So after few steps all instances of Print["progress",Dynamic[progress],"%"]; are changed for current step. I would like to this line of code to be dynamic only in one step of for loop.

  • $\begingroup$ F[x_]:=Module[{progress,...}, ...]? $\endgroup$ – Kuba Mar 19 '19 at 11:11
  • 4
    $\begingroup$ Have you seen Monitor and PrintTemporary? (ProgressIndicator could also be useful). $\endgroup$ – Sjoerd Smit Mar 19 '19 at 11:19

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.