script progress for slow script

hi there

i have an quite slow script (duplicating all address book cards) whitch takes ca 2 minutes to run.

is it possbilbe to give the user during this piriod some UI progress feedback, that something is happening and what it is?

thanks, olli

Of course anything you do will increase the total time.

However you could do something like this…

set total_cards to count of … – the count of the major repeat
set done_cards to 0

In the major repeat loop …

set done_cards to done_cards + 1 – or use the repeat index

— every 50 or so cards

say (done_cards as string) & " of " & (total_cards as string) & " done."

or

display dialog (done_cards as string) & " of " & total_cards & " done." giving up after 1 – show dialog for 1 second only

Also, I’m not sure if you are looking at using an interface, but in that case you can easily add a progress indicator (a bar) that will increment as the progress completes.

i thought of this, but it is a little bit silly to show something, wait and hide it, instead of showing something and just proceeding without hiding the info.

but i guess AS doesn’t give me that much control over its UI output.

olli

what is “an interface”? how can i acess it via AS?

thanks, olli

Well, the easiest way to build an interface for an application like that would be to use Xcode and Interface Builder under the OSX Developer Tools. If you play around with that, it is quite easy to make exactly what you are describing with a traditional Apple progress bar throughout the entire process.