How to use progress bar
Rob Cozens
rcozens at pon.net
Sun Jun 6 11:20:50 EDT 2004
Bill,
>In your loop you need to set the thumbPosition of the scrollbar to a value
>and it will move. Here's an example for a progress bar based on the total
>number of cards:
Ken's handler should do the job; but if you want something a little
more generic:
put the number of cards into recordCount
set the thumbPosition of scrollBar "Progress Scrollbar" to 0
set the endvalue of scrollBar "Progress Scrollbar" to recordCount
show scrollBar "Progress Scrollbar"
put 0 into recordsProcessed
put round(recordCount/(the width of scrollBar "Progress Scrollbar"))
into progressInterval -- the minimum change in thumbPosition value to
move the bar 1 pixel
put max(1,progressInterval) into progressInterval -- adjust for intervals < 1
repeat with x=1 to recordCount
set cursor to busy
[card processing logic here]
add 1 to recordsProcessed
if (recordsProcessed mod progressInterval)=0 then set the
thumbPosition of scrollBar "Progress Scrollbar" to recordsProcessed
end repeat
set the thumbPosition of scrollBar "Progress Scrollbar" to
recordCount -- yes, recordCount: make sure progress shows 100%
complete
This logic calculates the minimum value change required to move the
thumbPosition 1 pixel based on the length of the progress bar in
pixels and the endValue. It only updates the progress bar when the
aggregate change in thumbPosition value is large enough to move the
thumbPosition 1 pixel. (Eg: Assuming a 100 pixel progress bar, the
thumbPosition would be updated every card in a 100-card stack, every
10 cards in a 1,000-card stack, every 100 cards in a 10,000-card
stack.) Note the interval adjusts automatically when the length of
the progress bar is changed.
--
Rob Cozens
CCW, Serendipity Software Company
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list