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 »

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: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Progress bars 101

Post by bn »

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 346 times
quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: Progress bars 101

Post by quailcreek »

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: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Progress bars 101

Post by FourthWorld »

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: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Progress bars 101

Post by Klaus »

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

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

Re: Progress bars 101

Post by bn »

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: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Progress bars 101

Post by Klaus »

Hallo Bernd,

heissen Dank für diese Info :)
Post Reply