# Using Dynamic[] function

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:

For[i=0,i<=100,
x=i*dx;
u=F[x];
(* do sth with u *)
i++;
]


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.

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