• 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
Help with AppleScripting iCal and Lion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with AppleScripting iCal and Lion


  • Subject: Help with AppleScripting iCal and Lion
  • From: Tim Cimbura <email@hidden>
  • Date: Thu, 27 Oct 2011 20:51:43 -0500

The following script…is failing with Lion. Worked fine under Snow Leopard. Any ideas?
Any ideas on how to gracefully exit if the calendar doesn't exist?

Thanks,
Tim

tell application "FileMaker Pro"
tell current record
-- Format of date on the layout must be "1/5/03 8:00 pm" or similar
   set theStartDateTime to cell "ciCalStartDateTime"
   set theEndDateTime to cell "ciCalEndDateTime"
   set theSummary to cell "ciCalSummary"
   set alarmMinutesBefore to cell "iCalAlarmHoursBefore" * -1 * 60 -- 1 day earlier reminder (60 minutes * 24 hours)
   set theCalendar to cell "Bookings_PrefsX::iCalCalendarName"
end tell
end tell

set theStartDateTime to date theStartDateTime -- Reformat the date correctly
set theEndDateTime to date theEndDateTime

set alarmMinutesBefore to alarmMinutesBefore as number

tell application "iCal"
-- Find the calendar with this name
set theCal to ""
repeat with i from 1 to count of every calendar
if title of (item i of every calendar) is theCalendar then set theCal to i
end repeat

-- If the calendar does not exist then create one
if theCal is "" then
make new calendar with properties {writable:true} & {title:theCalendar}
repeat with i from 1 to count of every calendar
if title of (item i of every calendar) is theCalendar then set theCal to i
end repeat
end if
try
set new_event to make event at end of events of calendar theCal with properties {start date:theStartDateTime, end date:theEndDateTime, summary:theSummary}
tell new_event
  make mail alarm at end of mail alarms with properties {trigger interval:alarmMinutesBefore}
make display alarm at end of display alarms with properties {trigger interval:alarmMinutesBefore}
end tell
end try

    view calendar at (theStartDateTime)
    activate
end tell



Tim Cimbura

Helping businesses become more effective, productive, and profitable through custom iPad/iPhone applications, FileMaker solutions, and web site design. 





2796 118th Circle NE • Blaine MN 55449-5047
763-355-5243 office • 509-561-0161 fax • 612-298-0086 Mobile
email@hidden • www.cimbura.com

LinkedIn | FaceBook | Twitter | YouTube | Tech Blog | Speaking Blog


 _______________________________________________
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

  • Prev by Date: Re: launchd user agent applescript do shell script error
  • Next by Date: Re: launchd user agent applescript do shell script error
  • Previous by thread: Remote Disks
  • Next by thread: Re: Help with AppleScripting iCal and Lion
  • Index(es):
    • Date
    • Thread