Problem creating iCal events in Panther

I have searched the forums high and low looking for the proper way to format the part of my new script dealing with iCal events. I thought I had it down with the following:


set this_month to (month of (current date)) as string
set first_day to (date this_month)
set mycalander to "work"
tell application "iCal"
	make new event at beginning of events of calendar mycalander with properties {summary:"Backup", start date:first_day, description:"Some Discription", recurrence:"FREQ=MONTHLY;INTERVAL=1"}
end tell

This works in Tiger, but in Panther running iCal v1.5.5 I get the error: NSContainerSpecifierError
Unfortunatly I have to get the script to work in Panther. Any help you folks can give would be most appriciated!

Hi,

on my machine your script doesn’t work either in Tiger, the date calculation isn’t correct.
I assume you want an all day event at first day of current month.
The NSContainerSpecifierError stands for, that there’s no end date specified but a start date.

Try this, it should work in Tiger and Panther:

-- startTime: 1. day of current month 0:00:00, endTime: 2. day of current month 0:00:00
tell (current date) to set {startTime, endTime} to {it - time - ((its day) - 1) * days, it - time - ((its day) - 2) * days}
set mycalander to "work"
tell application "iCal"
	make new event at beginning of events of calendar mycalander with properties {summary:"Backup", start date:startTime, end date:endTime, allday event:true, description:"Some Discription", recurrence:"FREQ=MONTHLY;INTERVAL=1"}
end tell

Hi,

I don’t know if Panther is the same as Jaguar, but here I got it to work by getting a reference to the calendar through its title. You can’t reference calendars by name.


set this_month to (month of (current date)) as string
set first_day to (date this_month)

set mycalander to "Work"
tell application "iCal"
	set the_cal to first calendar whose title is mycalander
	make new event at end of events of the_cal with properties {summary:"Backup", start date:first_day, description:"Some Discription", recurrence:"FREQ=MONTHLY;INTERVAL=1"}
end tell

gl,

Hi kel,

hm, very strange, Script Debugger shows “calendar 1 (Named “xxx”)”
but you’re right, it doesn’t work in Panther

Filters work, however:

tell application "iCal" to set bdCals to item 1 of (every calendar whose title contains "Birthdays")
--> calendar 5

Yes, good to know to do it always for compatibility :wink:

Thank you guys so much!
Using filters did the trick in both Tiger and Panther.