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:

  1. Save the file workspace.daysUntilEvent.ftsc to a temporary location on your computer.

  2. Open the Radio application.

  3. Use File, Open to find and open workspace.daysUntilEvent.ftsc. A dialog box appears asking for the name to give the imported object.

  4. Accept the default, workspace.daysUntilEvent.ftsc, and click OK. 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.

Once the script has been installed at workspace.daysUntilEvent, you can call it on any page of your Radio weblog. It takes the following arguments, in this order:
  1. target Day of Month

  2. target Month

  3. target Year

  4. target Hour (optional)

  5. target Minute (optional)

  6. 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:

  1. Open Radio.

  2. Choose Tools, Developers, Quick Script. The Quick Script window opens.

  3. Enter scheduler.addTask (clock.now(), "radio.weblog.publish()", 1440) and click Run. 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.

-- Rogers Cadenhead

Add a Comment

These HTML tags are permitted: p, b, i, a, and blockquote. A comment may not include more than three links. Participants in this discussion should note the site's moderation policy.

:
:
: