Re: Undefined Variable
Re: Undefined Variable
- Subject: Re: Undefined Variable
- From: KOENIG Yvan <email@hidden>
- Date: Mon, 22 Sep 2008 18:56:10 +0200
Le 22 sept. 2008 à 18:15, K.Olson a écrit :
Relative noob here.
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:
"The variable thisLocation is not defined."
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 tell
My guess is that at least for some values of n, set location of
thisEvent returns nothing
I got this kind of behavior one hour ago.
My workaround was
set thisLocation to location of thisEvent
try
set thisLocation to thisLocation
on error
set thisLocation to ""
end try
…
Yvan KOENIG (from FRANCE lundi 22 septembre 2008 18:56:05)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden