Progress Bar Example

Jeff Honken jhonken at x12.info
Fri Mar 24 18:18:24 EST 2006


Sarah,
  Thanks for the reply.  I've tried using 
load stack URL http://www.x12help.com/x12provider.rev" but it errors.
I've only been successful with "go"  Here's the code I'm using in a
button:

on mouseUp
  go stack URL "http://www.x12help.com/x12provider.rev"
end mouseUp

Is there some other syntax for "load" ?

Jeff


           -----Original Message-----
From: use-revolution-bounces at lists.runrev.com
[mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of Sarah
Reichelt
Sent: Friday, March 24, 2006 2:42 PM
To: How to use Revolution
Subject: Re: Progress Bar Example

On 3/25/06, Jeff Honken <jhonken at x12.info> wrote:
>
> I would like to use a "progress bar" to monitor a "go stack URL".  I'm
> clueless on how to write the code.  Does someone have an example of
this
> or can someone please point me in the correct direction. Jeff

I haven't done it using stacks, but I have done it for downloading
pictures from the web and I guess it's much the same. Firstly, you
need to use "load" instead of "go". This is non-blocking and reports
it's status so you can show what's happening.

Here is part of the handler I use to start a download. It sets the
status callback object to a progress bar and then starts loading. When
it is finished, it's going to call the "picDownloaded" handler.


on downloadFile pAddress
  libURLSetStatusCallback "showStatus", the long ID of sb "Progress"
of stack "Download"
  load URL pAddress with message "picDownloaded"
end downloadFile

In the script of the scrollbar, I have this:

on showStatus pURL, pStatus
  if item 1 of pStatus = "loading" then
    put item 2 of pStatus into tNow
    put item 3 of pStatus into tEnd

    if the visible of sb "Progress" = false then
      -- hasn't started yet
      set the endValue of  sb "Progress" to tEnd
      set the thumbPos of  sb "Progress" to tNow
      show  sb "Progress"
    else
      set the thumbPos of  sb "Progress" to tNow
    end if

  else if pStatus = "error" then
    libURLSetStatusCallback
    set the dialogData to empty
    close this stack
   end if
end showStatus

which sets the range of the progress bar and shows it if not already
visible, otherwise it just moves the progress bar. If there is an
error, it gets out.

Back in my download script, I have the handler that gets called after
the download is finished. This is in the same script as the
downloadFile handler:

on picDownloaded pURL, pStatus
    libURLSetStatusCallback
    set the dialogData to URL pURL
    unload URL pURL
 end picDownloaded

This puts the newloy downloaded data into a variable (I'm using the
dialogData as it downloads from a separate dialog stack), and then
unloads the file so that it isn't held in two places of memory at
once.

At this point, you could have a "go to stack pURL" line.

Let me know if this doesn't work or if you have any further questions.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution






More information about the Use-livecode mailing list