ShowProgressBar

Revision as of 20:18, 19 February 2009 by Lchrisman (talk | contribs)


ShowProgressBarDialog.jpg

Declaration

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

Description

Displays or updates a programmable dialog containing a progress bar. 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


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 nice to include a textual indication of the percent complete. A nice way to do this is to introduce a User-Defined Function:

Function FormatPct( x : number ) := "" & x
{ Set the number format for this function to Percent }

Then use:

ShowProgressBar( "Progress", FormatPct(p) & " Complete", p )

where p is your measure of percent complete.

Analytica Web Player and ADE

The progress bar does nothing in ADE or Analytica Web Player. It doesn't hurt anything being there, but the progress bar dialog only appears when evaluated in desktop Analytica.

See Also

Comments


You are not allowed to post comments.