I would like to work with the events of a subset of my calendars.
set calendars_to_ignore to {"foo", "bar"}
tell application "iCal"
set calendars_list to name of every calendar as list whose name is not in calendars_to_ignore
repeat with current_calendar in calendars_list
-- ... do something ...
end repeat
end tell
I’ve also tried
...
set calendars_list to name of every calendar as list
repeat with current_calendar in (calendars_list whose name is not in content of calendars_to_ignore)
...
and variations of that.
But both times I get an error like “error “ž{"foo", "bar"} whose not 64” could not be read.” number -1728
I guess I’m mixing lists with records, but obviously I haven’t understood any one of them properly…
Can anybody please point me in the right direction?
set calendars_to_ignore to {"foo", "bar"}
tell application "iCal"
set calendars_list to name of every calendar
repeat with current_calendar in calendars_list
if current_calendar is not in calendars_to_ignore then
-- do something
end if
end repeat
end tell
Nah, that didn’t work out when it’s added to the grand scheme of things…
After inserting the if-clause, the rest of the script barfs. And I am totally puzzled as to why…
It looks as if the calendars, once referenced by name, are now only available as ids…
set calendars_to_ignore to {"foo", "bar"}
set current_date to current date
tell application "iCal"
-- Search through all calendars, one by one
repeat with current_calendar in calendars
-- alternative way to write would be:
--set calendars_list to name of every calendar
--repeat with current_calendar in calendars_list
--if current_calendar is not in calendars_to_ignore then
-- Wade through all events in each calendar that occur in the defined time frame
repeat with current_event in ((every event of current_calendar) whose ((start date ≥ current_date)))
-- do something
end repeat
--end if
end repeat
end tell
set calendars_to_ignore to {"foo", "bar"}
tell application "iCal"
set calendars_list to every calendar
repeat with current_calendar in calendars_list
if (name of current_calendar) is not in calendars_to_ignore then
-- do something with the calendar
-- now current_calendar is the actual calendar rather than just the name
end if
end repeat
end tell
THANK YOU regulus6633 (it works! :lol: ) and StefanK (it makes everything quicker by a factor of 5 = 500% :D).
As a newbie to AS-scripting I follow the orders given http://macscripter.net/guidelines.php and “proffer my script” (read: me reinventing the wheel). And it’s not even my script, I’d say. Just copied and pasted.