• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Undefined Variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Undefined Variable


  • Subject: Undefined Variable
  • From: "K.Olson" <email@hidden>
  • Date: Mon, 22 Sep 2008 11:15:57 -0500

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 tel
 _______________________________________________
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

  • Follow-Ups:
    • name of this document
      • From: Ronald Hofmann <email@hidden>
    • Re: Undefined Variable
      • From: KOENIG Yvan <email@hidden>
  • Prev by Date: Re: Google - Imap - Mail Problem
  • Next by Date: Re: Google - Imap - Mail Problem
  • Previous by thread: Is the 'dialogs' parameter in Illustrator's 'open' command broken?
  • Next by thread: Re: Undefined Variable
  • Index(es):
    • Date
    • Thread