progress bar and loop example

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
bbrink
Pro Scripter
Posts: 70
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

progress bar and loop example

Post by bbrink » Sun Nov 12, 2017 2:10 am

I have a script that loops through some records. I'd like a status bar since this can run anywhere from seconds to 10 or 15 minutes. I found the sample code I will post below. My question is, how do I update the bar as part of processing my loop?

thanks again, -Bob

My loop is similar to this:

Let>k=0
Repeat>k
Let>k=k+1
// do something
Until>k=5

Here is the sample status bar I have:

//Progress bar dialog
Dialog>dlgProgress
Caption=Progress
Width=451
Height=67
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=0
Resize=0
progressbar=bar1,0,8,441,16,0
EndDialog>dlgProgress

Let>dlgProgress.bar1=1
Show>dlgProgress
Let>progress=0
Repeat>progress
Add>progress,1
Wait>0.05
// do stuff
// ...
// ...

// now update the progress bar
Add>dlgProgress.bar1,1
ResetDialogAction>dlgProgress
Until>progress=100

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: progress bar and loop example

Post by JRL » Sun Nov 12, 2017 4:57 am

You need to have all going on happening in one loop so combine the two. Since the "k" loop only loops five times the progress bar is increasing by 20 each loop cycle.

Code: Select all

Here is the sample status bar I have:
//Progress bar dialog
Dialog>dlgProgress
Caption=Progress
Width=451
Height=67
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=0
Resize=0
progressbar=bar1,0,8,441,16,0
EndDialog>dlgProgress
Let>dlgProgress.bar1=1
Show>dlgProgress
Let>progress=0
Let>k=0
Repeat>k
Let>k=k+1
// do something
// now update the progress bar
Add>dlgProgress.bar1,20
ResetDialogAction>dlgProgress
Wait>1
Until>k=5
Add>progress,1

bbrink
Pro Scripter
Posts: 70
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

Re: progress bar and loop example

Post by bbrink » Sun Nov 12, 2017 12:08 pm

Awesome! Thank you for this. -Bob

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts