Help with iCal's open file alarm

Hi,

I am trying to link my script with iCal’s “open file alarm” but having difficulty with creating the event in iCal. I searched the forums here for the same problem but found nothing that could help - or might have missed any if there was. Sorry if I did.

Here are the snippet of my codes where I ran into the problem:


tell calendar myCal
	make new open file alarm at end with properties {trigger interval:(myTrigger as integer), trigger date:(alarmDate as date), filepath:(P6PathToAppas Unicode text}
end tell

Please take a look at the codes and point where I am wrong. The error I got with the above “make” command is:

myTrigger is integer; alarmDate is in date; and, P6PathToApp is POSIX path in Unicode text format.

Incidentally, the iCal dictionary says;
trigger date (date) : An absolute alarm date

What does this mean? Is this given as date or total seconds from the event time? I am confused here. Nevertheless, even if I remove this trigger date property (assuming I was wrong in supplying the date data), the problem with “NSContainerSpecifierError” error persista. It must, therefore, be in the specifier (in the property record) of the “make” command code and that’s the one I do not know.

Thank you for your help.

archseed :frowning:

Hi,

Sorry I mistyped the portion “filepath:(P6PathToAppas Unicode text”.

It should be “filepath:(P6PathToApp as Unicode text” which I have in my script.

Thanks.

archseed :slight_smile:

Hi,

this means that the container is not specified to put the alarm in.
Try this

tell calendar myCal
	make new open file alarm at end of open file alarms with properties {trigger interval:(myTrigger as integer), trigger date:(alarmDate as date), filepath:(P6PathToApp as Unicode text}
end tell

Thanks Stefan,

I tried your suggestion and got this error message:

Looks like we have a problem with incorrect referencing here. I tried some variations but never got around the problem.

I will keep trying.

archseed :frowning:

of course you must address a certain event.
The structure is


tell application "iCal"
	tell calendar myCal
		tell event myEvent
			make new open file alarm at end of open file alarms with properties {trigger interval:(myTrigger as integer), trigger date:(alarmDate as date), filepath:(P6PathToApp as Unicode text)}
		end tell
	end tell
end tell

Hi,

I tried creating an event first and then setting up an open file alarm within that event.

This is now successfully done - event was created within the iCal calendar on the start and end dates that I specified. However, I would like to set the recurrence to “every day” and the end to “never”. I tried to set the recurrence property to “every day” in the “make” command but I could not get the event to set it properly.

There is a part about “recurrence” in the iCal dictionary under the class “event” that I could not understand →

Can someone tell me more about setting this “recurrence” property of an iCal event?

Thank you very much.

archseed :slight_smile:

Hi Stefan,

Now that I said something about my event, I realize that you had it written up in your suggestion.

Sorry, I miss that one badly but I am glad that I learned something on my own and arrived at the same point - still I must thank you.

Now, if only you could help me with this recurrence enigma.

TIA,

archseed :slight_smile:

Hi Stefan (again),

I missed your post but it’s alright. Thanks for the correction.

Now, if only I could set the “recurrence” properly then I would simply insert the corrected “open file alarm” code inside the event to complete the linking of my script with iCal.

Thanks in advance,

archseed :slight_smile:

Hi,

you can find it out doing some investigations.

Create the recurrence manually in iCal, then
run this script:

tell application "iCal"
	get recurrence of events of calendars
end tell

in the result field you will see all recurrences and the code

Great tip, Stefan!

I would never have figured it out. Off and going, I am. Thanks a lot!

Cheers.

archseed :smiley:

Hi Stefan and All,

I managed to get all things working onto link up my script with iCal but things don’t look quite normal it seems. Thanks for the tip on checking the recurrence thing manually. All I had to do was paste the list value in the recurrence property of my “make” alarm event.

For info of anyone who might have a use for this, when making the “open file alarm” inside the alarm event I found out, for unfathomable reasons, that it does not accept any specification for date properties: start date and end date. The only way I could make it to work is by specifying the start date and end date in separate lines inside the tell block instead of including them in the property section when creating the event. [Correction]: actually, the script will compile successfully but the values specified by the date properties are not entered.

Does anyone know why? It seems from the iCal dictionary that this would not require separate codes. I would be interested to revise my codes for brevity’s sake.

Here’s some code snippets to show what I mean:

tell application "iCal"
	activate
	set myCalendars to name of every calendar whose writable is true
	set selCalendar to (choose from list myCalendars with prompt "Attach to which calendar?" without multiple selections allowed and empty selection allowed) as text
	set alarmDescription to "Type in the description of the event here.."
	
	set alarmEvent to make new event at end of event of calendar selCalendar with properties {summary:(archivingEvent as Unicode text), recurrence:({"FREQ=DAILY;INTERVAL=1"} as Unicode text), description:alarmDescription}
	tell alarmEvent
		make new open file alarm at beginning of open file alarms with properties {trigger interval:0, filepath:pathToApp}
		set the start date to startDate
		set the end date to endDate
	end tell
end tell

Thanks again for the help.

archseed :smiley:

Hi,

I have to answer my own question after all.

After checking the iCal dictionary, I realize that it was my mistake after all. The properties “start date” and “end date” are properties of the alarm event, not of the “open file alarm” event. Thus, I was trying to make the aforementioned properties work in the wrong place. They need to be inserted in the “make” alarm event before the “open file alarm” event is created.

Sorry, but I hope that clears up any confusion I might have caused.

archseed :smiley:

Hi Again,

In the interest of those who might be interested, I am posting here the corrected code snippets of my previous post. Please note where the “start date” and “end date” properties ended up.

--Create the events in iCal using the data inputs from the user
	tell application "iCal"
		--get the existing calendars and let user choose the one to activate for the event
		set myCalendars to name of every calendar whose writable is true
		set thisCalendar to (choose from list myCalendars with prompt "Create the event in which calendar?" without multiple selections allowed and empty selection allowed) as text
		set alarmDescription to "Enter in this description section any notes of importance regarding the alarm event."
		
		--now, create the alarm event
		set alarmEvent to make new event at end of event of calendar thisCalendar with properties {summary:(archivingEvent as Unicode text), recurrence:(recurState as Unicode text), description:alarmDescription, start date:startDate, end date:endDate}
		
		--now, create within the alarm event the "open file alarm" event
		tell alarmEvent
			--make new open file alarm at beginning of open file alarms with properties {trigger interval:0, filepath:pathToApp}
			make new open file alarm at the end of open file alarms with properties {trigger interval:0, filepath:pathToApp}
			--set the start date to startDate
			--set the end date to endDate
		end tell
	end tell

Cheers!

archseed :smiley: