This is my first time scripting iCal. I am having problems understanding the best way to capture/validate a variable if it is undefined. For instance if I uncomment the try block I don't get an error. If I run this as is I get the expected dialogs for the first 5 entries (this calendar has 61 entries) or so then I get an Error:
I can try and capture and display what is going on and I think I see that thisEvent variable has no value for location. I think. I tried to enter a preliminary check on the variable thisLocation but it doesn't seem to catch the problem. This is obviously the start of a script that is in the building stage but I am stuck on getting past this.
property local1 : "Client One"
property theEvents : {}
tell application "iCal"
activate
set theEvents to every event of calendar 1 of application "iCal"
set eventCnt to count of theEvents
set event1 to item 1 of theEvents
--try
repeat with n from 1 to eventCnt
set thisEvent to item n of theEvents
set thisLocation to location of thisEvent
--try and reset the variable if it is empty
if thisLocation is null then
set thisLocation to "none"
else
set thisLocation to thisLocation
end if
if thisLocation is local1 then
display dialog "success"
else
display dialog "You are going to " & thisLocation
end if
end repeat
--end try
end tel