I created this progress bar to use in my codes:
progressBar1[var_,total_]:=Row[{ProgressIndicator[var,{0,total}]," ",
Row[{NumberForm[100. var/total,{\[Infinity],2}],"%"}],"% ",var}]
But to use it I have to implement like this:
Module[{n = 10, i = 0},
Print[Dynamic@progressBar1[i, n]];
(i++; Pause[0.1]) & /@ Range[n];
]
I tried to implement like this, but with no success.
progressBar2[var_,total_]:=Print[Dynamic@Row[{ProgressIndicator[var,{0,total}]," ",
Row[{NumberForm[100. var/total,{\[Infinity],2}],"%"}],"% ",var}]]
Module[{n=10,i=0},
progressBar2[i,n];
(i++;Pause[0.1])&/@Range[n];
]
The idea is to change progressBar2
to make it usable inside Module without necessity to call Dynamic and Print.
I've seen this similar post
How to create a progress bar?
, but didn't get how to upgrade my code.
Some clue?
Module[{n = 10, i = 0}, Print@ProgressIndicator[Dynamic[x]]; (i++; Pause[0.1]; x = i/n) & /@ Range[n];]
$\endgroup$Dynamic@i
is unavoidable. You need to tell Mma that something is changing ... $\endgroup$