2
$\begingroup$

How to express calculation time with ProgressIndicator.

I want to make the following CDF document.

 Manipulate[ 
     db = Table[ test2[i, number], {i, 2, end}]
   ; pos = Position[ db, True]
   ; seq = Table[ db[[pos[[i, 1]]]][[1]], {i, 1, Length[pos]}]

   , {{end, 1000, ""}, {1000, 2000, 3000}}
   , {{number, 3, ""}, {3, 4, 5}}
   , TrackedSymbols :> {end, number}
   , Initialization :> (
         test2[n_, number_] := Module[{}, 
             exp = Factor[x^n - 1]
           ; data = Table[CoefficientList[exp[[i]] , x], {i, 1, Length[exp], 1}]
           ; t1 = Table[MemberQ[Flatten@data, i], {i, number, number}]
           ; If[ MemberQ[ Flatten@t1, True], {n, True}, {n, False}]];
     ) 
]    

Plugging in and running the above CDF document into a web page takes a lot of computation time.

At this time, I would like to show the ProgressIndicator in the proper position during the calculation.

enter image description here

Because the user wants to know whether the calculation is in progress or whether the calculation is complete.

How can I express the information that the calculation is in progress or finished with ProgressIndicator?

$\endgroup$
4
$\begingroup$

You can use another ProgressIndicator with an Indeterminate range option. The latter will show "running" without a specific value:

Column@{
  ProgressIndicator[Dynamic[n], {1, 100}], 
  ProgressIndicator[Dynamic[n], Indeterminate]
  }
Table[(n = k; Pause[0.1]), {k, 1, 100}];

Alternatively, you can just write "Running..." and switch that to "done" when done:

Row@{ProgressIndicator[Dynamic[n], {1, 100}], " ", Dynamic[status]}
status = "Running...";
Table[(n = k; Pause[0.1]), {k, 1, 100}];
status = "Done!";
$\endgroup$
  • $\begingroup$ Thanks for the correct explanation. I solved the problem thanks to this. $\endgroup$ – user21427 May 10 '17 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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