Independent Progress Bar

Bob Sneidar bobs at
Thu Dec 15 12:07:13 EST 2011

On Dec 14, 2011, at 11:14 PM, FlexibleLearning wrote:

> If you want a modal progress bar that works independently (as in
> non-blocking) then open the modal invisible first and increment your own bar
> as required.
> Both will 'stall' if LC is performing a blocking and time-consuming
> operation unless it is returning a trappable value (such as a 'bites
> downloaded' callback) that you can use.
> Hugh Senior
> FLCo

Aye that's the rub. When opening a remote SQL server, or calling sqlYoga to do it for me, there is a time lapse, sometimes several seconds, during which all operations are blocking ones. mySQL is not going to give me progress reports, and unless Trevor decides to implement them, sqlYoga will not either. 

In any case there are many times that the blocking operations will take enough time that any attempt to automate the progress indicator will be jumpy at best, and completely fail at worst. 

My solution of creating a standalone stack with systemWindow set to true and a label and animated gif works perfectly for this. I hide the calling stack before calling spinnerOn so the user won't attempt to interact with the main application. Obviously this is an OS X solution for now. 

My calling scripts look like this:
on spinnerOn
    put "tell application " & quote & "spinner" & quote & cr & \
            "activate" & cr & \
            "end tell" & cr into theCommand
    do theCommand as Applescript
end spinnerOn

on sendMove
    put the loc of me into theLoc
    put "moveMe " & quote & theLoc & quote into theCommand
    send theCommand to program "spinner"
end sendMove

on sendMessage thePrompt
    put "setPrompt " & quote & thePrompt & quote into theCommand
    send theCommand to program "spinner"
end sendMessage

on spinnerOff
    put "hideMe" into theCommand
    send theCommand to program "spinner" -- we leave it running for future use
end spinnerOff

My scripts in the Spinner stack look like this:
on appleEvent theEvent
    request appleEvent data
    put it into theData
    if theEvent is "setPrompt" then
        setPrompt theData
    end if
    if theEvent is "moveMe" then
        moveMe theData
    end if
    if theEvent is "showMe" then
    end if
    if theEvent is "hideMe" then
    end if
    pass appleEvent
end appleEvent

on setPrompt theData
    set the text of field "lblSpinner" to theData
end setPrompt

on moveMe theLocation
    set the loc of me to theLocation
end moveMe

on showMe
    show me
end showMe

on hideMe
    hide me
end hideMe

on centerPrompt
    set the width of field "lblSpinner" to the formattedwidth of field "lblSpinner"
    set the loc of field "lblSpinner" to the loc of grc "Background"
    set the left of img "spinner" to the right of field "lblSpinner" +10
end centerPrompt

Works a peach. Anyone can easily do this themselves. 


More information about the Use-livecode mailing list