Apple has changed the scripting behavior on the buggy iCal once again, making old work-arounds no longer work. Looking for viable new work arounds.
- When fetching properties of events, in Leopard many properties would actually be missing values but return an undefined variable. in Leopard, I worked around that like this:
set someloc to location of some_event
try
set testit to someloc
on error
set someloc to ""
end try
now they actually DO property return missing value, so that work around code can be changed to this:
set someloc to location of some_event
try
set testit to someloc
if someloc is missing value then set someloc to ""
on error
set someloc to ""
end try
so far so good. but…
- what about SETTING the missing value? At least for some properties, you get an error:
tell application "iCal"
set te to some event of calendar "Testing" whose summary contains "testing event"
set recurrence of te to missing value
end
end tell
result:
error “iCal got an error: Can’t make missing value into type text.” number -1700 from missing value to text
huh? now it wants text?
ok so…
- if you set the recurrence property to a blank string (“”) then it works without error, however the event does not actually SHOW UP in the iCal GUI.
When you set the recurrence (repeat) to NONE in the iCal GUI, the property is actually changed back to missing value.
Huh? so what’s the work around now?
- Tiger to Snow Leopard compatibility and event ID/UID.
This is untested so far, but to retain Tiger backwards compatibility in Leopard, I had to use:
if hasleopard then
set good_event to some event of calendar t_cal whose uid is t_id
--set good_event to some event of calendar t_cal whose uid is t_id -- when compiled on Leopard
--set good_event to some event of calendar t_cal whose id is t_id -- when compiled on tiger
else
set good_event to some event of calendar t_cal whose uid is t_id
--set good_event to some event of calendar t_cal whose «class wr10» is t_id -- when compiled on Leopard
--set good_event to some event of calendar t_cal whose uid is t_id -- when compiled on Tiger
end if
Can’t recall for sure now, but this <> used to compile correclty for use in Tiger… Now it compiles as UID in both cases. Still needs testing.