iCal To Do Alarms

I’m writing a script to make iCal ToDos repeat. It identifies To Dos that need to repeat and clones them according to a specified repeat interval (will post more info when it’s complete).

It all works fine with one exception. A To Do with an open file alarm gets cloned with an run script alarm with same file name but with .scpt added to the end.

The iCal dictionary defines only 4 types of alarms, display, mail, sound, and open file. But in iCal itself, 5 types of alarms are available - message, message with sound, email, open file, and run script (in addition to none of course)

Here’s the code I use to copy over the open file alarms from one ToDo to another:


set myAlarms to open file alarms of thisToDo
			repeat with j from 1 to (count of myAlarms)
				set myTriggerInterval to trigger interval of item j of myAlarms
				set myFilePath to filepath of item j of myAlarms
				if trigger date of item j of myAlarms exists then
					set myTriggerDate to trigger date of item j of myAlarms
					set newTriggerDate to CalcDate(myTriggerDate, myRepeatType, myRepeatInterval) of me
					tell newToDo to make new open file alarm at end of open file alarms of newToDo with properties {trigger date:newTriggerDate, filepath:myFilePath}
				else
					tell newToDo to make new open file alarm at end of open file alarms of newToDo with properties {trigger interval:myTriggerInterval, filepath:myFilePath}
				end if

There’s similar code that copies over the other types of alarms.

Am I doing something wrong or is there a missing alarm type in the iCal dictionary or maybe a missing property in the open file alarm definiton that defines if the file is a script or not?

Thanks,

Pete
PS Edited this - forgot to mention that the original open file alarm names a compiled script.

PPS One more edit. Been playing with this a bit more and found that the type of alarm created in the new To Do is somewhat random, for example, sometimes a message alarm is created. I also noticed that the dictionary defines the file path as being a Posix file path so I changed my make statement to include “filepath:POSIX path of myFilePath”. Now the correct type of alarm is created but the full file path of the file is displayed in iCal instead of just the actual filename. Thsi causes an error when the alarm is execute “file cannot be found”