...
The concept of a stack allows multiple operations to be nested by pushing another operation onto the stack before popping the first one off. For example:
Code Block | ||
---|---|---|
| ||
progressBar -push -text "Operation A";// Pushes Operation A |
...
progressBar -push -text "Operation B";// Pushes Operation B |
...
progressBar -pop; // Pops Operation B |
...
progressBar -pop; // Pops Operation A |
Besides giving feedback to the user during lengthy operations, adding progressBar commands to your script also enables the user to cancel execution of the script using the Cancel button on the status bar. The Cancel button is disabled otherwise.
...
Scroll tablelayout | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
void
Scroll pagebreak |
---|
Examples
Code Block | ||
---|---|---|
| ||
// Demonstrate range setting, stepping, and nesting of operations |
...
int $i, $j, $timeKiller, $maxI = 20, $maxJ = 2000; |
...
// Push a new operation onto the stack. |
...
progressBar -push -range 1 $maxI -text "Outer"; |
...
for( $i = 0; |
...
$i < $maxI; |
...
$i += 1 ) |
...
{ |
...
// This increments the "Outer" operation |
...
progressBar -step; |
...
// Kill some time so the stepping effect is visible. |
...
$timeKiller = 0; |
...
while( $timeKiller < 5000 ) |
...
{ |
...
$timeKiller += 1; |
...
} |
...
// Push another operation onto the stack, which nests |
...
// this operation in the "Outer" one. |
...
progressBar -push -range 1 $maxJ -text "Inner"; |
...
for( $j = 0; |
...
$j < $maxJ; |
...
$j += 1 ) |
...
{ |
...
// This increments the "Inner" operation |
...
progressBar -step -text string( $j ); |
...
} |
...
// This pops the "Inner" operation off the stack. |
...
progressBar -pop; |
...
} |
...
// Finally, this pops the "Outer" operation off the stack. |
...
progressBar -pop; |
Additional information
Related commands
...