| EverythingDigital | RSS Feed | Flickr Photos | What Is Podcasting? |


« PSP Countdown App Update | Main | The AppleScript Countdown »

March 11, 2005

The PSP Countdown's Source

I am making the source of my PSP Launch Countdown App available to all, with the hope that others will expand on the idea and make their own AppleScript countdowns. It's fairly easy to change the code, simply by adjusting the psplaunchdate variable to the desired countdown's end. There are a couple references to the PSP that pop up in the dialog boxes, but those can easily be changed to meet the specifications for a different countdown. Read on to see the source, or download the original ApleScript script file below.

Download The Script File (.scpt)



Here is the AppleScript code used to compile the application. Have fun, and see what other countdowns you can come up with. Be sure to post them here in the comments when you finish them.

repeat
set todaydate to current date
set todayday to day of todaydate
set todaytime to time of todaydate

set psplaunchdate to date "Thursday, March 24, 2005 12:00:00 AM"
set psplaunchday to day of psplaunchdate
set psplaunchtime to time of psplaunchdate

set daysleft to psplaunchday - todayday
set timeleft to 86400 - todaytime

set totaltimeleft to timeleft + {86400 * daysleft}
set unroundedminutesleft to totaltimeleft / 60
set totalminutesleft to {round unroundedminutesleft}
set unroundedhoursleft to totalminutesleft / 60
set totalhoursleft to {round unroundedhoursleft}
set unroundeddaysleft to totalhoursleft / 24
set totaldaysleft to {round unroundeddaysleft}


if totaltimeleft is less than or equal to 0 then
display dialog "The PSP is here!"
exit repeat

else
display dialog "There are...

" & totaldaysleft & " days,

" & totalhoursleft & " hours,

" & totalminutesleft & " minutes, or

" & totaltimeleft & " seconds left until the PSP's launch.

This dialog will auto-refresh every 10 seconds, or you can manually refresh it by clicking OK." giving up after 10

end if
end repeat

Posted by Alan Joyce at March 11, 2005 08:18 PM

Trackback Pings

TrackBack URL for this entry:
http://www.everythingdigital.org/cgi-bin/mt-tb.cgi/138

Comments

Yey! Open source! You are making the right choice. Good job.

Posted by: Jeff at March 11, 2005 09:31 PM

why not just do it like this:

set todaydate to current date

set psplaunchdate to date "Thursday, March 24, 2005 12:00:00 AM"

set timeleft to psplaunchdate - todaydate

set daysleft to {round (timeleft / 86400)}
set hoursleft to {round (timeleft mod 86400 / 3600)}
set minutesleft to {round (timeleft mod 86400 mod 3600 / 60)}

set myTime to (daysleft as string) & "d " & (hoursleft as string) & "h " & (minutesleft as string) & "m to PSP"

and then do something useful with it.
Looks nicer IMHO, and also works for other months than the present one.

Posted by: Erik Swedberg at August 31, 2005 09:35 AM

Post a comment




Remember Me?



(You must preview before you post. This is to prevent spam.)