Friday, July 30, 2010

#1 2003-07-22 11:27:25 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Pseudo Progress Bar

This one just came to me and I love it. Maybe it's just because I'm cheap and don't want to spring for Extra Suites or 24UAppearance.osax. This is also good when you don't need the overhead of a full AS Studio app but really want a progress bar.

OS version:

Applescript:

set total_count to 10
set iteration to 1

repeat while iteration less than or equal to total_count
   set main_string to "This is a pseudo progress bar."
   set sub_string to ("Processing item " & (iteration as string) & " of " & (total_count as string) & "...")
   my display_progress(iteration, total_count, main_string, sub_string)
   --do something
   set iteration to (iteration + 1)
end repeat
display dialog "All done." buttons {"OK"} default button 1 with icon 1 giving up after 10

on display_progress(iteration, total_count, main_string, sub_string)
   --choose from this list for the "unprocessed" part of the progress bar
   set the_counter_opts to {" ", "-------------------------------------------", "oooooooooooooooooooooooooooooooooooooooo"}
   set the_counter to (characters of (item 2 of the_counter_opts))
   set the_percentage to (round of ((iteration / total_count) * (count of the_counter)) rounding down)
   if the_percentage is not equal to 0 then
       repeat with i from 1 to the_percentage
           set item i of the_counter to "•"
       end repeat
   end if
   set the_counter to the_counter as string
   set the_message to main_string & return & return & sub_string & return & return & the_counter
   display dialog the_message buttons {"Cancel"} giving up after 1
end display_progress


One mans trash is another mans treasure

Offline

 

#2 2007-07-02 12:43:43 pm

returnofthemac
Member
From: Boston, MA
Registered: 2007-06-19
Posts: 17
Website

Re: Pseudo Progress Bar

I know this might be obvious but I need to get that progress bar into this script:


Applescript:

set f to choose folder with prompt "Choose a destination for your backup"
set username to short user name of (system info)
set source to POSIX path of ((path to home folder as Unicode text) & "Library:Mail:")
set destination to POSIX path of f & "Mail_" & username & ".zip"
do shell script ("/usr/bin/ditto -c -k -rsrc --keepParent " & quoted form of source & " " & quoted form of destination)
beep 3
display dialog "Your mail folder is backed up. now BACK TO WORK!!" buttons {"Yes, Sir."} default button 1

Where would I put it? I'm not sure how I'm supposed to use it. Sorry, I'm INCREDIBLY new at this. Any help is very much appreciated


and yes, I would love to fix your computer.

Offline

 

#3 2007-07-02 03:15:45 pm

StefanK
Member
From: Sankt Gallen, Switzerland
Registered: 2006-10-21
Posts: 7316
Website

Re: Pseudo Progress Bar

Hi returnofthemac,

the pseudo progress bar works only within a loop.
Your script "waits" in the shell script line until the zip-archive has been created.
There is no way to interact.


regards

Stefan

Offline

 

#4 2010-07-12 06:03:55 am

McUsr
Member
From: Southern Norway
Registered: 2010-04-07
Posts: 635

Re: Pseudo Progress Bar

Hello.

I have made a new version of  original display_progress with some nice Unicode characters with permission by:

Jon Nathan
JNSoftware LLC JNSoftware - Products


Applescript:


property script_name : "Pseudo Progress Bar"
property script_description : "This one just came to me and I love it. Maybe it's just because I'm cheap and don't want to spring for Extra Suites or 24UAppearance.osax. This is also good when you don't need the overhead of a full AS Studio app but really want a progress bar."

— © Jon Nathan JNSoftware LLC
— McUsr Tinkered with Unicode Characters and new rounding 2010

set total_count to 10
set iteration to 1

repeat while iteration is less than or equal to total_count
   set main_string to "This is a pseudo progress bar."
   set sub_string to ("Processing item " & (iteration as string) & " of " & (total_count as string) & "...")
   my display_progress(iteration, total_count, main_string, sub_string)
   --do something
   set iteration to (iteration + 1)
end repeat
display dialog "All done." buttons {"OK"} default button 1 with icon 1 giving up after 10

on display_progress(iteration, total_count, main_string, sub_string)
   --choose from this list for the "unprocessed" part of the progress bar
   set the_counter_opts to {" ", "▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢▢", "▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣▣"}
   set the_counter to (characters of (item 2 of the_counter_opts))
   set the_percentage to (round of ((iteration / total_count) * (count of the_counter)) rounding up)
   if the_percentage is not equal to 0 then
       repeat with i from 1 to the_percentage
           set item i of the_counter to "â–£"
       end repeat
   end if
   set the_counter to the_counter as string
   set the_message to main_string & return & return & sub_string & return & return & the_counter
   display dialog the_message buttons {"Cancel"} giving up after 1
end display_progress

Best Regards

McUsr

Last edited by McUsr (2010-07-12 06:07:56 am)


Best Regards
             
McUsr

Filed under: PseudoProgressBar

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.245 seconds, 9 queries executed ]

RSS (new topics) RSS (active topics)