On the West Highland Way weblog, James McReady is counting down the days until a sponsored charity walk is talking place.
Right now, he's providing the countdown manually by editing the text himself.
I wrote a short UserTalk script that can count down to any specified date in the future:
To use it:
- Save the file workspace.daysUntilEvent.ftsc to a temporary location on your computer.
- Open the Radio application.
- Use workspace.daysUntilEvent.ftsc. A dialog box appears asking for the name to give the imported object.
- Accept the default, workspace.daysUntilEvent.ftsc, and click . If you already have a copy of this script (or another script with the same name), you'll be asked if it should be replaced.
- target Day of Month
- target Month
- target Year
- target Hour (optional)
- target Minute (optional)
- target Second (optional)
The optional arguments all default to zero, causing the countdown to use midnight as the time if no hour, minute, or second are specified.
Here's a countdown to Christmas:
<% workspace.daysUntilEvent(25, 12, 2003) %>
As of the last time this page was published, there are [Macro error: Can't call the script because the name "daysUntilEvent" hasn't been defined.] days until Christmas 2003.
Here's a countdown to Millard Fillmore's 204th birthday:
<% workspace.daysUntilEvent(7, 1, 2004) %>
There are [Macro error: Can't call the script because the name "daysUntilEvent" hasn't been defined.] days until Fillmore's birthday.
Radio only runs a macro on a page when the page has been updated. If you're putting the countdown clock on your weblog's home page, you can make it publish automatically once a day using the scheduler.addTask verb:
- Open Radio.
- Enter scheduler.addTask (clock.now(), "radio.weblog.publish()", 1440) and click . The page will be published once a day at the same time you ran the script.
The clock.now verb returns a value representing the current second. You can use a different value for the first argument to cause the page to be published earlier or later in the day. Just add the number of seconds until it should first be run -- for example, scheduler.addTask(clock.now() + 79200, "radio.weblog.publish()", 1440) runs it 22 hours in the future, then every 24 hours after that.