-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprogress-bar-example.applescript
65 lines (58 loc) · 2.23 KB
/
progress-bar-example.applescript
1
use AppleScript version "2.4" -- Yosemite (10.10) or lateruse framework "Foundation"use scripting additionson run set theList to {"Marlow", "Maddie", "Sammy", "Stuey", "Jessie", "Tolstoy"} set the itemCount to the count of theList set progress total steps to the itemCount repeat with i from 1 to itemCount set thisItem to item i of theList set progress description to "Item " & i & " of " & itemCount set progress additional description to thisItem -- The delay is simply to simulate processing time -- so you can see the progress bar in action. -- Exclude this from your code. delay 1 set progress completed steps to i end repeatend run-- ---------------------- FUNCTIONS-- ---------------------- The example above shows the raw method for implementing progress bars.-- The functions below are convenience wrappers for the same code to keep-- your overall code much cleaner and less repetitive.-- Create the initial progress bar.-- @param {int} steps The number of steps for the process -- @param {string} descript The initial text for the progress bar-- @param {string} descript_add Additional text for the progress bar-- @returns voidon progress_start(steps, descript, descript_add) set progress total steps to steps set progress completed steps to 0 set progress description to descript set progress additional description to descript_addend progress_start-- Update the progress bar. This goes inside your loop.-- @param {int} n The current step number in the iteration-- @param {int} steps The number of steps for the process -- @param {string} message The progress update message-- @returns voidon progress_update(n, steps, message) set progress additional description to message & n & " of " & stepsend progress_update-- Increment the step number of the progress bar.-- @param {int} n The current step number in the iteration-- @returns voidon progress_step(n) set progress completed steps to nend progress_step-- Clear the progress bar values-- @returns voidon progress_end() -- Reset the progress information set progress total steps to 0 set progress completed steps to 0 set progress description to "" set progress additional description to ""end progress_end