Applescript & iCal announce multiple events

Nice script. Think I’d rather have the short user name.

kel1 try…
set userName to short user name of (system info)
Or
set userName to do shell script “whoami”

Also you can try this script I found…


tell application "System Events"
	set full_name to full name of current user as string
	set first_name to first word of full_name as string
end tell
say "Hello " & first_name & ", hey,   whats up?"

Hi.

That should be its hours, otherwise you get 3600.

And the Sunday greetings should be the first in the list at the top of the script. AppleScript weeks start on Sundays.

Of course, thanks.

I tested it on 22:30 local time, so it didn’t catch my eyes at once :wink:

Edit: I changed the script accordingly

Since I can’t figure out a way to get reoccurring dates on the calendar to get spoken in the Event script I figured out a work-around, by manually setting up personal dates “Holiday’s, Birthdays…” in a stand alone script. This gets spoken after the greeting script, before the current weather forecast.


-- Personal Event Reminder
set {year:y, month:m, day:d} to (current date)

set m to (month of (current date)) as integer
set d to (day of (current date))
set y to (year of (current date))

set MyEvents to {m, d}

if MyEvents = {1, 1} then
	say "Happy New Year! Welcome to," & (y)
	
else if MyEvents = {1, 16} then
	say "Today is Chris's Birthday."
	
else if MyEvents = {2, 2} then
	say "Happy Groundhog Day."
	
else if MyEvents = {2, 14} then
	say "Happy Valentine's Day!"
	
else if MyEvents = {3, 17} then
	say "Happy I hate my liver day, a.k.a. St. Patrick's Day!"
	
else if MyEvents = {4, 15} then
	say "Today is Tax day!"
	
else if MyEvents = {6, 4} then
	say "Happy 4th of July. Let's blow some shit up!"
	
else if MyEvents = {10, 31} then
	say "Trick or Treat, Happy All Hallows Eve!"
	
else if MyEvents = {12, 14} then
	say "Happy Birthday Sara!"
	
else if MyEvents = {12, 23} then
	say "2 Days till Chrismas! I hope you've finished all your shopping."
	
else if MyEvents = {12, 24} then
	say "It's Christmas Eve!"
	
else if MyEvents = {12, 25} then
	say "Merry Christmas!"
	
else if MyEvents = {12, 31} then
	say "Happy New Years Eve! Say goodbye to" & (y)
	
end if

Hi soxmonky.

Here’s a slight reworking of your script.

  1. It’s better to call ‘current date’ only once if only one date’s involved.
  2. The nested ‘if’ system I’ve used below reduces the number of tests done overall. For instance, today’s 5th January, for which there are no events. Rather than testing all the conditions {1, 1} thru {12, 31} before not saying anything, the nested system only tests for January and then for 1 and 16. After that, the action cuts to the end of the main ‘if’ block. Similarly, if today were 31st December, the nested system would only need to test the months to match December before testing the days thereof, rather than testing every single month/day condition for which there are greetings:

-- Personal Event Reminder
set {year:y, month:m, day:d} to (current date)

if (m is January) then
	if (d is 1) then
		say "Happy New Year! Welcome to," & (y)
	else if (d is 16) then
		say "Today is Chris's Birthday."
	end if
	
else if (m is February) then
	if (d is 2) then
		say "Happy Groundhog Day."
	else if (d is 14) then
		say "Happy Valentine's Day!"
	end if
	
else if (m is March) then
	if (d is 17) then say "Happy I hate my liver day, a.k.a. St. Patrick's Day!"
	
else if (m is April) then
	if (d is 15) then say "Today is Tax day!"
	
else if (m is June) then
	if (d is 4) then say "Happy 4th of July. Let's blow some shit up!"
	
else if (m is October) then
	if (d is 31) then say "Trick or Treat, Happy All Hallows Eve!"
	
else if (m is December) then
	if (d is 14) then
		say "Happy Birthday Sara!"
	else if (d is 23) then
		say "2 Days till Chrismas! I hope you've finished all your shopping."
	else if (d is 24) then
		say "It's Christmas Eve!"
	else if (d is 25) then
		say "Merry Christmas!"
	else if (d is 31) then
		say "Happy New Years Eve! Say goodbye to" & (y)
	end if
end if

Thanks NG for the tune-up on that script. I’m still learning!
I also figured out a nifty script for calculating the age of someone, that I slipped into that script for peoples Birthday’s. It could also be tweaked for anniversaries too…
All you need to do is replace the year in “set birthdate to (year)”


set {year:y, month:m, day:d} to (current date)
--
if (m is May) then
	if (d is 23) then
		set birthdate to (2007)
		set age to y - birthdate
		say "Today is Allison's Birthday, she turns" & age
	end if

Hi soxmonky,

Great stuff. It looks as if you’ll be having some fun with this. :slight_smile:

By the way, I didn’t mean to imply that your own ‘if.else’ layout wasn’t perfectly adequate for the current job. I was just offering the programme-flow tip for general consideration. It only saves a microsecond or two per run here!

Just putting the final touches on a Movie Calendar script, that plays every Friday morning. I want to include it into my main morning script but just skip over it if its not Friday. I’ve been playing around with (currentweekday) but nothing has worked yet.

Movie Calendar is below… (Auto-refresh: Every Week) - Ignore Alerts
https://www.google.com/calendar/ical/pfutdblf1gi8jmfsvroh76f6jg%40group.calendar.google.com/public/basic.ics


set today to (current date)
set today's time to 0
set tomorrow to today + 7 * days
set myMovies to {}
set numberOfMovies to (count myMovies)

set movieHours to hours of (current date)
if movieHours is less than 10 then
	set timeofDay to "Today"
else if movieHours is less than 14 then
	set timeofDay to "This Afternoon"
else if movieHours is less than 18 then
	set timeofDay to "This Evening"
else
	set timeofDay to "Tonight"
end if

tell application "Calendar"
	set futureMovies to every event of calendar "Movies" whose start date ≥ today and end date ≤ tomorrow
end tell
repeat with anEvent in futureMovies
	tell application "Calendar" to set {summary:movieTitle, start date:theStartDate, allday event:theTimes, description:movieNotes, location:movieLocation} to anEvent
	
	set movieSummary to summarize movieNotes in 1
	
	set movieDay to (weekday of theStartDate)
	
	set moviePlots to {", Here is a quick plot synopsis of the film.", ", Here is a little bit about the film.", ", Here is a short plot summary of the movie.", ", Let's take a look at the films synopsis.", ", Here's some details about the movie.", ", Here is some information about the movie."}
	set moviePlot to some item of moviePlots
	
	set theTimes to {"There is a movie entitled,", timeofDay & "You could go see,", "Showing" & timeofDay & ", is,", "You might want to see,", "There is a new film titled,", "Opening this " & movieDay & ", is,", timeofDay & "You might be interested in,", "Now showing,", "Now playing,", "Playing this " & movieDay & ", is,", "Playing " & timeofDay & ", is,"}
	set theTime to some item of theTimes
	
	set the end of myMovies to theTime & movieTitle & ", in." & movieLocation & moviePlot & " . " & movieSummary
end repeat

set numberOfMovies to (count myMovies)
if (numberOfMovies is less than 1) then
	set firstGreetings to {"There are no new movies opening" & timeofDay, "I was unable to find any new movies opening this weekend.", "Looks like a slow weekend for Holywood. There is no new movies premiering" & timeofDay, "There is nothing new showing at the movie theater this weekend.", "You might want to watch something on Netflix" & timeofDay & ", there is nothing new at your local theater."}
	set firstGreeting to some item of firstGreetings
	say firstGreeting
else if (numberOfMovies is equal to 1) then
	set secondGreetings to {"Here's a quick look at whats at the movies, " & timeofDay, "Let's see whats playing at the movie theaters this weekend., I have found one new movie opening " & movieDay, "Here's what is being released this weekend at the movies.", "There is one new movie premiering.", "Who's up for a movie this " & movieDay}
	set secondGreeting to some item of secondGreetings
	say secondGreeting
	delay 1
	say item 1 of myMovies
else
	set thirdGreetings to {"I've found" & numberOfMovies & "new movies you might be interested in seeing this " & movieDay, "There are" & numberOfMovies & " new movies opening this weekend.", "Now showing at a movie theater near you!..." & numberOfMovies & "new movies have just been released" & timeofDay, "I have found " & numberOfMovies & " movies opening" & timeofDay, "Here is a look at whats playing " & movieDay & " at the movie theater.", "Who's up for a movie, " & timeofDay & "There are " & numberOfMovies & "new releases."}
	set thirdGreeting to some item of thirdGreetings
	say thirdGreeting
	delay 1
	repeat with thismovie in myMovies
		say thismovie
		delay 0.6
	end repeat
end if

if (numberOfMovies ≥ 1) then
	say "Check online for" & timeofDay & "'s showtimes, trailers, movie reviews & tickets."
	
set theURL to "http://trailers.apple.com/trailers/showtimes/"
	tell application "Safari"
		activate
		try
			tell window 1 to set current tab to make new tab with properties {URL:theURL}
		on error
			open location theURL
		end try
	end tell
end if

Does anyone know if theres away to incorporate CalendarLib into this script to make it go faster?
http://macscripter.net/viewtopic.php?id=44523

For some reason the allday property wasn’t included in CalendarLib’s event info, but you should be able to change this:

tell application "Calendar"
	set futureMovies to every event of calendar "Movies" whose start date ≥ today and end date ≤ tomorrow
end tell
repeat with anEvent in futureMovies
	tell application "Calendar" to set {summary:movieTitle, start date:theStartDate, allday event:theTimes, description:movieNotes, location:movieLocation} to anEvent

To this:

set theStore to fetch store
set theCal to fetch calendar "Movies" cal type cal local event store theStore -- change to suit
set futureMovies to fetch events starting date today ending date tomorrow searching cals {theCal} event store theStore
repeat with anEvent in futureMovies
	set theId to event identifier for event anEvent
	tell application "Calendar" to set {summary:movieTitle, start date:theStartDate, allday event:theTimes, description:movieNotes, location:movieLocation} to event id theId

And add a use script “CalendarLib” line.

Thanks Shane!

Any ideas on how to apply it to the original Calendar script not just the movie one? I’ve tried with very little success :frowning:

I can’t keep up. Give me a message number, or post it again.

Shane here is the original calendar script THANKS


set calendarNames to {"Home", "Work", "Calendar"}

set today to (current date)
set today's time to 0
set tomorrow to today + days
set myMeetings to {}

set {year:y, month:m, weekday:w, day:d, hours:h} to (current date)

set calHours to h
if calHours < 12 then
	set timeofDay to "this Morning"
else if calHours < 16 then
	set timeofDay to "this Afternoon"
else if calHours < 19 then
	set timeofDay to "this Evening"
else
	set timeofDay to "Tonight"
end if

repeat with calName in calendarNames
	-- Get the start dates of all the events in this calendar.
	-- It could take some time if there are a lot of events.
	tell application "Calendar" to set thisCalendarsStartDates to start date of every event of calendar calName
	
	-- Examine the start dates and act on those which occur today.
	repeat with evnt from 1 to (count thisCalendarsStartDates)
		set theStartDate to item evnt of thisCalendarsStartDates
		if ((theStartDate is greater than or equal to today) and (theStartDate is less than tomorrow)) then
			-- If this start date occurs today, get further information from the event to which it belongs.
			tell application "Calendar" to set {summary:theSummary, end date:theEndDate, allday event:allDayEvent} to event evnt of calendar calName
			
			-- If the event's a 24-hour all-day event, or an ordinary event which ends today, prepare appropriate spoken text.
			set theTime to missing value
			if (allDayEvent) then
				if (theEndDate is theStartDate + days) then set theTime to "First, there is an All-day event"
			else if (theEndDate is less than or equal to tomorrow) then
				-- Get a representation of the start time in 12-hour time.
				set {hours:Eventhour, minutes:Eventminute} to theStartDate
				set pre to item (Eventhour div 12 + 1) of {"AM", "PM"}
				set Eventhour to (Eventhour + 11) mod 12 + 1
				if (Eventminute is 0) then set Eventminute to ""
				set theTime to "at " & Eventhour & " " & Eventminute & " " & pre
			end if
			-- Put both the start date and the meeting text into the meetings list as a pair.
			if (theTime is not missing value) then set the end of myMeetings to {theStartDate, theTime & " you have scheduled, " & theSummary}
		end if
	end repeat
end repeat

-- Custom comparer for a customisable sort. It compares lists by their first items.
script sortOnItem1
	on isGreater(a, b)
		return (item 1 of a > item 1 of b)
	end isGreater
end script

-- Sort items 1 thru -1 of myMeetings using sortOnItem1 to compare them ” ie. sort on the start dates.
CustomInsertionSort(myMeetings, 1, -1, {comparer:sortOnItem1})

-- Speak the prepared texts (item 2 of each item of myMeetings) in order.
set greetings to {"Let's take a quick look at your calendar:", "Let's see what you have going on today:", "Let's see how busy your day looks:", "Here's whats on your calendar:"}
set greeting to some item of greetings

set schedules to {"You currently have nothing scheduled on your calendar for ", "I was unable to locate any appointments on your calendar for ", "You currently have nothing on your calendar for ", "Your calendar has no pending appointements at this time for "}
set schedule to some item of schedules

#say greeting
#delay 0.5
set numberOfMeetings to (count myMeetings)
if (numberOfMeetings is 0) then
	set preamble to schedule & timeofDay
else if (numberOfMeetings is 1) then
	set preamble to greeting & "I could only locate one event for" & w
else
	set preamble to greeting & "You better get moving, there are " & numberOfMeetings & " upcoming appointments."
end if
say preamble
delay 1
repeat with thismeeting in myMeetings
	say item 2 of thismeeting
	delay 0.5
end repeat

on CustomInsertionSort(theList, l, r, customiser)
	script o
		property comparer : me
		property slave : me
		property lst : theList
		
		on isrt(l, r)
			set u to item l of o's lst
			repeat with j from (l + 1) to r
				set v to item j of o's lst
				if (comparer's isGreater(u, v)) then
					set here to l
					set item j of o's lst to u
					repeat with i from (j - 2) to l by -1
						tell item i of o's lst
							if (comparer's isGreater(it, v)) then
								set item (i + 1) of o's lst to it
							else
								set here to i + 1
								exit repeat
							end if
						end tell
					end repeat
					set item here of o's lst to v
					slave's shift(here, j)
				else
					set u to v
				end if
			end repeat
		end isrt
		
		-- Default comparison and slave handlers for an ordinary sort.
		on isGreater(a, b)
			(a > b)
		end isGreater
		
		on shift(a, b)
		end shift
	end script
	
	-- Process the input parameters.
	set listLen to (count theList)
	if (listLen > 1) then
		-- Negative and/or transposed range indices.
		if (l < 0) then set l to listLen + l + 1
		if (r < 0) then set r to listLen + r + 1
		if (l > r) then set {l, r} to {r, l}
		
		-- Supplied or default customisation scripts.
		if (customiser's class is record) then set {comparer:o's comparer, slave:o's slave} to (customiser & {comparer:o, slave:o})
		
		-- Do the sort.
		o's isrt(l, r)
	end if
	
	return -- nothing.
end CustomInsertionSort

First, you need to download the latest version. I’ve just updated it to include the information on whether an event is all-day or not. So your script should begin:

use script "CalendarLib" version "1.1.1" -- this script won't work with earlier versions
use scripting additions

And then the main part you want would be like this:

set theCalendars to {}
set theStore to fetch store
repeat with i from 1 to count of calendarNames
	set theCal to fetch calendar (item i of calendarNames) cal type cal local event store theStore -- change to suit
	set end of theCalendars to theCal
end repeat
set theEvents to fetch events starting date today ending date tomorrow searching cals theCalendars event store theStore
repeat with anEvent in theEvents
	set {event_summary:theSummary, event_end_date:theEndDate, all_day:allDayEvent} to event info for event anEvent
	-- do your stuff here
end repeat

You can then also remove all the sorting code.

Thanks Shane seems to work pretty good, however it still requires me to have the Calendar app running for the script to work. I get a Syntax Error: Expected end of line, etc. but found class name. But the script does run slightly faster than before. Thank you for your help!


use script "CalendarLib" version "1.1.1" -- this script won't work with earlier versions
use scripting additions

set today to (current date)
set today's time to 0
set tomorrow to today + days
set myMeetings to {}

set {year:y, month:m, weekday:w, day:d, hours:h} to (current date)

set calHours to h
if calHours < 12 then
	set timeofDay to "this Morning"
else if calHours < 16 then
	set timeofDay to "this Afternoon"
else if calHours < 19 then
	set timeofDay to "this Evening"
else
	set timeofDay to "Tonight"
end if

set theCalendars to {"Home", "Work", "Calendar"}
repeat with calName in theCalendars
	-- Get the start dates of all the events in this calendar.
	-- It could take some time if there are a lot of events.
	tell application "Calendar" to set thisCalendarsStartDates to start date of every event of calendar calName
	
	-- Examine the start dates and act on those which occur today.
	repeat with evnt from 1 to (count thisCalendarsStartDates)
		set theStartDate to item evnt of thisCalendarsStartDates
		if ((theStartDate is greater than or equal to today) and (theStartDate is less than tomorrow)) then
			-- If this start date occurs today, get further information from the event to which it belongs.
			tell application "Calendar" to set {summary:theSummary, end date:theEndDate, allday event:allDayEvent} to event evnt of calendar calName
			
			-- If the event's a 24-hour all-day event, or an ordinary event which ends today, prepare appropriate spoken text.
			set theTime to missing value
			if (allDayEvent) then
				if (theEndDate is theStartDate + days) then set theTime to "First, there is an All-day event"
			else if (theEndDate is less than or equal to tomorrow) then
				-- Get a representation of the start time in 12-hour time.
				set {hours:Eventhour, minutes:Eventminute} to theStartDate
				set pre to item (Eventhour div 12 + 1) of {"AM", "PM"}
				set Eventhour to (Eventhour + 11) mod 12 + 1
				if (Eventminute is 0) then set Eventminute to ""
				set theTime to "at " & Eventhour & " " & Eventminute & " " & pre
			end if
			-- Put both the start date and the meeting text into the meetings list as a pair.
			if (theTime is not missing value) then set the end of myMeetings to {theStartDate, theTime & " you have scheduled, " & theSummary}
		end if
	end repeat
end repeat

-- Custom comparer for a customisable sort. It compares lists by their first items.
script sortOnItem1
	on isGreater(a, b)
		return (item 1 of a > item 1 of b)
	end isGreater
end script

-- Speak the prepared texts (item 2 of each item of myMeetings) in order.
set greetings to {"Let's take a quick look at your calendar:", "Let's see what you have going on today:", "Let's see how busy your day looks:", "Here's whats on your calendar:"}
set greeting to some item of greetings

set schedules to {"You currently have nothing scheduled on your calendar for ", "I was unable to locate any appointments on your calendar for ", "You currently have nothing on your calendar for ", "Your calendar has no pending appointements at this time for "}
set schedule to some item of schedules

#say greeting
#delay 0.5
set numberOfMeetings to (count myMeetings)
if (numberOfMeetings is 0) then
	set preamble to schedule & timeofDay
else if (numberOfMeetings is 1) then
	set preamble to greeting & "I could only locate one event for " & w
else
	set preamble to greeting & "You better get moving, there are " & numberOfMeetings & " upcoming appointments."
end if
say preamble
delay 1
repeat with thismeeting in myMeetings
	say item 2 of thismeeting
	delay 0.5
end repeat

That’ll be because you haven’t actually replaced the code. Try this:

use script "CalendarLib" version "1.1.1" -- this script won't work with earlier versions
use scripting additions

set today to (current date)
set today's time to 0
set tomorrow to today + days
set myMeetings to {}

set {year:y, month:m, weekday:w, day:d, hours:h} to (current date)

set calHours to h
if calHours < 12 then
	set timeofDay to "this Morning"
else if calHours < 16 then
	set timeofDay to "this Afternoon"
else if calHours < 19 then
	set timeofDay to "this Evening"
else
	set timeofDay to "Tonight"
end if

set theCalendarNames to {"Home", "Work", "Calendar"}
set theStore to fetch store
set theCalendars to fetch calendars theCalendarNames cal type list {} event store theStore
set theEvents to fetch events starting date today ending date tomorrow searching cals theCalendars event store theStore
repeat with anEvent in theEvents
	set {event_summary:theSummary, event_end_date:theEndDate, all_day:allDayEvent} to event info for event anEvent
	-- If the event's a 24-hour all-day event, or an ordinary event which ends today, prepare appropriate spoken text.
	set theTime to missing value
	if (allDayEvent as boolean) then
		if (theEndDate is theStartDate + days) then set theTime to "First, there is an All-day event"
	else if (theEndDate is less than or equal to tomorrow) then
		-- Get a representation of the start time in 12-hour time.
		set {hours:Eventhour, minutes:Eventminute} to theStartDate
		set pre to item (Eventhour div 12 + 1) of {"AM", "PM"}
		set Eventhour to (Eventhour + 11) mod 12 + 1
		if (Eventminute is 0) then set Eventminute to ""
		set theTime to "at " & Eventhour & " " & Eventminute & " " & pre
	end if
	-- Put both the start date and the meeting text into the meetings list as a pair.
	if (theTime is not missing value) then set the end of myMeetings to {theStartDate, theTime & " you have scheduled, " & theSummary}
end repeat

-- Speak the prepared texts (item 2 of each item of myMeetings) in order.
set greetings to {"Let's take a quick look at your calendar:", "Let's see what you have going on today:", "Let's see how busy your day looks:", "Here's whats on your calendar:"}
set greeting to some item of greetings

set schedules to {"You currently have nothing scheduled on your calendar for ", "I was unable to locate any appointments on your calendar for ", "You currently have nothing on your calendar for ", "Your calendar has no pending appointements at this time for "}
set schedule to some item of schedules

#say greeting
#delay 0.5
set numberOfMeetings to (count myMeetings)
if (numberOfMeetings is 0) then
	set preamble to schedule & timeofDay
else if (numberOfMeetings is 1) then
	set preamble to greeting & "I could only locate one event for " & w
else
	set preamble to greeting & "You better get moving, there are " & numberOfMeetings & " upcoming appointments."
end if
say preamble
delay 1
repeat with thismeeting in myMeetings
	say item 2 of thismeeting
	delay 0.5
end repeat

Ha YUP that would do it! Thanks
However Im getting

it seems to be stoping at


set theCalendars to fetch calendars theCalendarNames event store theStore

I’ve edited the script to fix the offending line.

Thanks for all your work Shane!
I had to tweak a few lines to get it to work properly, had to change “event_end_date” to “event_start_date” to get it to run all the way through. But now it works like a charm and MUCH faster than the older script!


use script "CalendarLib" version "1.1.1" -- this script won't work with earlier versions
use scripting additions

set today to (current date)
set today's time to 0
set tomorrow to today + days
set myMeetings to {}

set {year:y, month:m, weekday:w, day:d, hours:h} to (current date)

set calHours to h
if calHours < 12 then
	set timeofDay to "this morning"
else if calHours < 16 then
	set timeofDay to "this afternoon"
else if calHours < 19 then
	set timeofDay to "this evening"
else
	set timeofDay to "tonight"
end if


set theCalendarNames to {"Home", "Work", "Calendar"}
set theStore to fetch store
set theCalendars to fetch calendars theCalendarNames cal type list {} event store theStore
set theEvents to fetch events starting date today ending date tomorrow searching cals theCalendars event store theStore
repeat with anEvent in theEvents
	set {event_summary:theSummary, event_start_date:startD, all_day:allDayEvent} to event info for event anEvent
	
	-- If the event's a 24-hour all-day event, or an ordinary event which ends today, prepare appropriate spoken text.
	set adjectives to {"Next ", "Also, ", "After that, ", "Later ", "Following that, ", "Following ", "Then, "}
	set adjective to some item of adjectives
	
	
	set theTime to missing value
	if (allDayEvent as boolean) then
		set theTime to "First, there is an All-day event"
	else if (startD ≤ tomorrow) then
		-- Get a representation of the start time in 12-hour time.
		set {hours:Eventhour, minutes:Eventminute} to startD
		set pre to item (Eventhour div 12 + 1) of {"AM", "PM"}
		set Eventhour to (Eventhour + 11) mod 12 + 1
		if (Eventminute is 0) then set Eventminute to ""
		
		if ((count myMeetings) ≥ 1) then
			set theTime to adjective & "@ " & Eventhour & " " & Eventminute & " " & pre
		else
			set theTime to "@ " & Eventhour & " " & Eventminute & " " & pre
		end if
		
		#set theTime to "at " & Eventhour & ":" & Eventminute & " " & pre
	end if
	
	set scheduled to {" you have scheduled, ", " you have, ", " you have listed, "}
	set schedule to some item of scheduled
	
	-- Put both the start date and the meeting text into the meetings list as a pair.
	if (theTime is not missing value) then set the end of myMeetings to {startD, theTime & schedule & theSummary}
end repeat

-- Speak the prepared texts (item 2 of each item of myMeetings) in order.
set greetings to {"Let's take a quick look at your calendar: ", "Let's see what you have going on today: ", "Let's see how busy your day looks: ", "Here's whats on your calendar: "}
set greeting to some item of greetings

set schedules to {"You currently have nothing scheduled for ", "I was unable to locate any appointments on your calendar for ", "You currently have nothing on your calendar for ", "Your calendar has no pending appointements for ", "Looks like today would be a great day to play hooky, I have found no upcoming appointments on your calendar "}
set schedule to some item of schedules

set numberOfMeetings to (count myMeetings)
if (numberOfMeetings is 0) then
	set preamble to schedule & timeofDay
else if (numberOfMeetings is 1) then
	set preamble to greeting & "I could only locate one event for " & w
else
	set preamble to greeting & "You have " & numberOfMeetings & " upcoming appointments."
end if
say preamble

delay 1
repeat with thismeeting in myMeetings
	say item 2 of thismeeting
	delay 0.5
	
end repeat