Progress bars 101

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Progress bars 101

Post by quailcreek » Tue Mar 02, 2010 11:17 pm

Hello everybody,
I wanted to see if I could get a little progress bar 101. I'm looking to have a progress bar run during the time the user is importing and exporting data to and from a data storage file. I'm fairly familiar with Rev so I just need a kick start. Or if there is a tutorial on progress bars out there someplace that would be good too.

Thanks allot,
Tom
Tom
MacBook Pro OS Mojave 10.14

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Progress bars 101

Post by bn » Wed Mar 03, 2010 12:28 am

Tom,
I attach a little stack that shows a progress bar. I don't know if it is what you want.
Just a little note. To give feedback during a long transaction is definitely helpful for the user. On the other hand it takes time to refresh the screen and that adds to the execution time.
So you might have to decide just how much feedback you want to give, every time something changes or every tenth time or even 1000th depending on what you do. But you will find that out if you experiment a little with the progress bar.
regards
Bernd
Attachments
progressExample.rev.zip
(1.15 KiB) Downloaded 275 times

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Progress bars 101

Post by quailcreek » Wed Mar 03, 2010 3:17 am

Bernd,
Thank you. That's just what I needed. Not to say I won't have more questions but this will get me started nicely.

Tom
Tom
MacBook Pro OS Mojave 10.14

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Progress bars 101

Post by FourthWorld » Wed Mar 03, 2010 3:57 am

A tip about showing progress bars on Mac, FWIW: the Mac progress bar rendering is so computationally intensive that updating the progress bar any more frequently than absolutely necessary can significantly impair your process' overall performance.

One way to reduce the number of times you call it is to use the mod operator in your loop, updating it every hundred times (or whatever other number would make sense for the amount of iterations you're running) through the loop instead of every time:

Code: Select all

put 0 into i
repeat for each line tLine in tData
  add 1 to i
  if i mod 100 = 0 then
    set the thumbpos of sb 1 to i
  end if 
 -- other processing here:

end repeat
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Progress bars 101

Post by Klaus » Wed Mar 03, 2010 9:17 am

Could someone please tell me what a "Progress bar 101" is?

Thanks!

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Progress bars 101

Post by bn » Wed Mar 03, 2010 10:56 am

Klaus,
in the USA college/university courses often numbered, 101 beeing the very first course on a subject in the first year. So it means for beginners on a subject. I don't know how far they count but you could probably teach at least 999 :)
regards
Bernd

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Progress bars 101

Post by Klaus » Wed Mar 03, 2010 12:00 pm

Hallo Bernd,

heissen Dank für diese Info :)

Post Reply