Difference between revisions of "ShowProgressBar"

m (Fixed problem in example and made it simpler)
Line 25: Line 25:
  
 
:<code>Dynamic(initial_population,</code>
 
:<code>Dynamic(initial_population,</code>
::<code>ShowProgressBar]]( "Progress", "Computing a dynamic model, Time = " & Time, (@Time - 1)/size(Time));</code>
+
::<code>(ShowProgressBar( "Progress", "Computing a dynamic model, Time = " & Time, (@Time - 1)/size(Time));</code>
::<code>population[Time - 1] + births[Time - 1] - deaths[Time - 1] + net_immigration[Time - 1])</code>
+
::<code>population[Time - 1] + births[Time - 1] - deaths[Time - 1] + net_immigration[Time - 1]))</code>
  
You may find it nice to include a textual indication of the percent completeA nice way to do this is to introduce a [[User-Defined Function]]:
+
You may find it helpful to show percent completion of the computationYou might use a [[User-Defined Function]]:
  
:<code>Function FormatPct(x: number) := "" & x { Set the number format for this function to Percent }</code>
+
:<code>ShowProgressBar("Progress", "Calculation is " & NumberToText(p, "Percent", 0) & " complete", p)</code>
 
 
Then use:
 
:<code>ShowProgressBar("Progress", FormatPct(p) & " Complete", p)</code>
 
  
 
where <code>p</code> is your measure of percent complete.
 
where <code>p</code> is your measure of percent complete.
  
 
== Analytica Cloud Player and ADE ==
 
== Analytica Cloud Player and ADE ==
The progress bar does nothing in [[ADE]].  It doesn't hurt anything being there, but the progress bar dialog only appears when evaluated in desktop Analytica.
 
  
It was implemented in [[Analytica Cloud Player]] in build 3.0.0.7.
+
The progress bar works in [[Analytica Cloud Player]].  It doesn't appear in [[ADE]], but it doesn't hurt anything.
  
 
== See Also ==  
 
== See Also ==  

Revision as of 20:11, 24 March 2016


ShowProgressBar(title, text, p)

Declaration:

ShowProgressBar(title, text: Text atomic; p: number atomic)

Description

Displays or updates a programmable dialog containing a progress bar. The «p» parameter denotes "percent complete" of a computation in progress. The first time it is called with «p» < 1, the dialog appears. When 0 ≤ «p» < 1, a Cancel button is displayed and the progress meter is updated to the indicated proportion, allowing computation to continue while it is visible. If the user presses Cancel, the computation is aborted. When «p» = 1, an OK button is shown and the dialog waits until OK is pressed to return and then disappears. The dialog is also removed when «p» > 1 or a computation completes.

Example

Var xOrig := X;
Var result :=
for n[] := @Scenario do (
ShowProgressBar("Progress", "Computing Across All Scenarios", (n - 1)/size(scenario));
WhatIf(Y, X, xOrig[@Scenario = n])
);
ShowProgressBar("Progress", "Done", 1);
result
ShowProgressBarDialog.jpg

You can use a progress bar to track your progress through a Dynamic computation:

Dynamic(initial_population,
(ShowProgressBar( "Progress", "Computing a dynamic model, Time = " & Time, (@Time - 1)/size(Time));
population[Time - 1] + births[Time - 1] - deaths[Time - 1] + net_immigration[Time - 1]))

You may find it helpful to show percent completion of the computation. You might use a User-Defined Function:

ShowProgressBar("Progress", "Calculation is " & NumberToText(p, "Percent", 0) & " complete", p)

where p is your measure of percent complete.

Analytica Cloud Player and ADE

The progress bar works in Analytica Cloud Player. It doesn't appear in ADE, but it doesn't hurt anything.

See Also

Comments


You are not allowed to post comments.