• 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
Re: Scripting iCal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting iCal


  • Subject: Re: Scripting iCal
  • From: Paul Berkowitz <email@hidden>
  • Date: Wed, 12 May 2004 01:27:36 -0700

On 5/11/04 8:58 AM, "Jason Bourque" <email@hidden> wrote:

> I need to find out if an event exists so I don't create it twice. Events can
> be duplicates if based on name. So I am checking for uid "unique id". But
> can't get it to work.
>
> Tell calendar "Work"
>
> Exists event uid vUniqueID
>
> end
>
>
> Any help please.

Your first problem here is that calendars (like events) don't
have a 'name' property, so you need to do a whose clause by title, unless
you know the calendar number. It's

tell calendar "Work"

that's causing the error. Instead:

tell app "iCal"
set iCalendar to first calendar whose title is "Work"
tell iCalendar
-- see below
end tell
end tell


You also can't specify events either by name (event "Whatever") nor as you
tried by uid (event uid vUniqueID). You must be hoping iCal works like some
other app (better behaved) that you know. iCal's dictionary - calendar entry
- tells you that an event is an element of calendar which can be specified
in any of these ways:

event - by numeric index, before/after another element, as a range of
elements, satisfying a test

No mention of 'by name' , 'by summary' or 'by uid' there. But 'satisfying a
test' means whose clauses will work:


tell app "iCal"
set iCalendar to first calendar whose title is "Work"
tell iCalendar
try
--get first event whose summary is "Whatever" -- or:
get first event whose uid is vUniqueID
--on error
-- make new event
end try
end tell
end tell


Rather than go to all the trouble of storing these uids, using the first
command

get first event whose summary is "Whatever"

in a try block will tell you immediately if "Whatever" exists already. If it
does, you can choose another name or do nothing. If it doesn't (i.e. 'on
error'), make the event with summary "Whatever".

Maybe you should be checking also start date in the whose clause? There's
usually nothing wrong with having several events of the same name (summary)
as long as they're at different times. I'm sure that's why iCal does not
implement a 'name' property, so that you have to search for every, or first,
event of that summary or else also specify the start date.

--
Paul Berkowitz

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Scripting iCal
      • From: Jason Bourque <email@hidden>
References: 
 >Scripting iCal (From: Jason Bourque <email@hidden>)

  • Prev by Date: Re: email address from address book
  • Next by Date: Re: controlling remote application question
  • Previous by thread: Scripting iCal
  • Next by thread: Re: Scripting iCal
  • Index(es):
    • Date
    • Thread