Progress bars
Richard Gaskin
ambassador at fourthworld.com
Sat Mar 12 17:46:59 EST 2005
Lars Brehmer wrote:
> I can't seem to find a tutorial or any layman's explanations on putting
> a simple progress bar into my stacks. I have a stack that imports text
> data and creates the cards to store it on. If the file is large, it
> takes a while, so I'd like to build in a progress bars (on a separate
> subStack?) to give an idea how long the task will take. Where does it
> go and how do you set it up? A tutorial or a sample stack that has one
> would be terrific! Can anyone help me out here?
A MINI-TUTORIAL ON PROGRESS BARS
--------------------------------
Rev includes a flexible object type called "scrollbar" which serves as
standard scrollbars and also sliders and progress bars as well.
The three most relevant properties for use as a progress bar are:
- thumbPos: the position of the indicator
- startValue: the beginning of the progress range
- endValue: the end of the progress range
Check out the discussion of those entries in the Transcript Dictionary.
It's handy to use the abbreviated form of "scrollbar", which is simply "sb".
You could set up a progress bar in your text processing script like this:
on ProcessFile
-- Get file data:
answer file "Select a file:"
if it is empty then exit to top
put url ("file:"&it) into tData
put the number of lines of tData into tNumLines
--
-- Setup progress bar:
set the startValue of sb "progress" to 0
set the endValue of sb "progress" to tNumLines
set the thumbpos of sb "progress" to 0
show sb "progress"
--
-- process the text in a loop:
put 0 into i
repeat for each line tLine in tData
add 1 to i
set the thumbPos of sb "progress" to i
--
DoSomethingWith tLine
end repeat
--
hide sb "progress"
end ProcessFile
--
Richard Gaskin
Fourth World Media Corporation
__________________________________________________
Rev tools and more: http://www.fourthworld.com/rev
More information about the use-livecode
mailing list