Applescripting broken/buggy? Weird events....

Tags ( )

Hey,

So I'm one your 'via-MacZot' customers and was looking to use Clockwork as a platform for a few ideas.
However, at the first step, I'm hitting problems in using its (Apple)scripting abilities.

If I pull in the example script from http://www.hogbaysoftware.com/node/20, mainly:

tell application "Clockwork"
-- get selected timer
set t to selected timer

-- clear time, set to five minutes, set alarm mode and start. set display time of t to 0
set minutes of t to 5
set mode of t to alarm
set running of t to true
end tell

what happens is this:
1. the minutes get set to 5
2. the mode DOES NOT get set to Alarm (if it was Stopwatch)
3a. If the mode was already alarm before the 'set mode' then the step of 'set running' actually returns the value of alarm to 00:00:00 and thefore the alarm goes off immediately (as opposed to counting down from 5mins)
3b. If the mode was stopwatch before the 'set mode' the then the step of 'set running' actually changes the value of the stopwatch to 2082 days, 13 hours, 18 secs...and it starts counting up.

Any chance of a fix? I'm blocked at my first project !

The other thing is I've not managed to get the performAlarmAction stuff working yet either...but I've not collected the same level of info on it for your dissection.

Cheers,
Rob

In this case I think it's

In this case I think it's more the documentation that's broken and buggy. I recently made big changes to the way that applescript is supported, and unfortunately I made a number of changes that were not backwards compatible. I'll go update those scripts after this post, though you're likely to find a few other outdated ones around here if you look hard enough... please let me know when you run into them :)

In your script there are a few things to change.

First if the selected timer is running you need to first stop it or else you can change the mode or time (just like in the GUI). Setting the minutes just sets the minutes, it does clear out other fields, such as the seconds. The running property is now marked in the script dictionary as 'read only' and shouldn't be set, though applescript doesn't seem to enforce this. Here's a script that should do what you want I think, the big difference is the use of the start and stop commands to control the timer.


tell application "Clockwork"
set t to selected timer
stop t
set display time of t to 0
set minutes of t to 5
set mode of t to alarm
start t
end tell

Cool...we're getting

Cool...we're getting there....but not quite over the line yet!


set mode of t to alarm

doesn't work though.
Neither, not coincidentally I suspect, does


log mode of t as string

with the latter generating "Clockwork got an error: NSInternalScriptError" error.

Strange the script does work

Strange the script does work for me. It may be that I've made changes to my local copy of Clockwork, and that's why they work. What version of Clockwork are you using? I have Version 1.2 (35), though even if you have that version I still might have made some local changes that you don't have.

1.2 (35) here too

1.2 (35) here too

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.