text
stringlengths
0
15.7k
source
stringlengths
6
112
set theEvents to (theEvents's filteredArrayUsingPredicate:thePred)
lns3.scpt
end filter events
lns3.scpt
on filter events by pattern event list theEvents event summary theTitle : missing value event description desc : missing value event location theLocation : missing value using regex regexFlag : true
lns3.scpt
if regexFlag as boolean then
lns3.scpt
set theNSPredicate to current application's NSPredicate's predicateWithFormat_("title MATCHES %@", theTitle)
lns3.scpt
set theNSPredicate to current application's NSPredicate's predicateWithFormat_("title LIKE %@", theTitle)
lns3.scpt
set theEvents to (theEvents's filteredArrayUsingPredicate:theNSPredicate)
lns3.scpt
set theNSPredicate to current application's NSPredicate's predicateWithFormat_("hasNotes == %@ AND notes MATCHES %@", true, desc)
lns3.scpt
set theNSPredicate to current application's NSPredicate's predicateWithFormat_("hasNotes == %@ AND notes LIKE %@", true, desc)
lns3.scpt
if useRegex as boolean then
lns3.scpt
set theNSPredicate to current application's NSPredicate's predicateWithFormat_("location MATCHES %@", theLocation)
lns3.scpt
set theNSPredicate to current application's NSPredicate's predicateWithFormat_("location LIKE %@", theLocation)
lns3.scpt
end filter events by pattern
lns3.scpt
on remove event event theEvent event store theStore future events futureFlag : true
lns3.scpt
set {theResult, theError} to theStore's removeEvent:theEvent span:futureFlag commit:true |error|:(reference)
lns3.scpt
if not theResult as boolean then error (theError's localizedDescription() as text)
lns3.scpt
end remove event
lns3.scpt
on create event event store theStore destination calendar theCal event summary theTitle starting date startD ending date endD runs all day allDay : false event location theLocation : missing value event description desc : missing value
lns3.scpt
set newEvent to current application's EKEvent's eventWithEventStore:theStore
lns3.scpt
newEvent's setCalendar:theCal
lns3.scpt
newEvent's setTitle:theTitle
lns3.scpt
newEvent's setStartDate:startD
lns3.scpt
newEvent's setEndDate:endD
lns3.scpt
newEvent's setAllDay:allDay
lns3.scpt
if theLocation is not missing value then newEvent's setLocation:theLocation
lns3.scpt
if desc is not missing value then newEvent's setNotes:desc
lns3.scpt
return newEvent
lns3.scpt
end create event
lns3.scpt
on modify event event theEvent destination calendar theCal event summary theTitle : missing value starting date startD : missing value ending date endD : missing value runs all day allDay : missing value event location theLocation : missing value event description desc : missing value
lns3.scpt
if theCal is not missing value then theEvent's setCalendar:theCal
lns3.scpt
if theTitle is not missing value then theEvent's setTitle:theTitle
lns3.scpt
if startD is not missing value then theEvent's setStartDate:startD
lns3.scpt
if endD is not missing value then theEvent's setEndDate:endD
lns3.scpt
if allDay is not missing value then theEvent's setAllDay:allDay
lns3.scpt
if theLocation is not missing value then theEvent's setLocation:theLocation
lns3.scpt
if desc is not missing value then theEvent's setNotes:desc
lns3.scpt
return theEvent
lns3.scpt
end modify event
lns3.scpt
on modify zone event theEvent time zone tz
lns3.scpt
if tz is missing value then
lns3.scpt
theEvent's setTimeZone:tz
lns3.scpt
set tz to (current application's NSArray's arrayWithObject:tz)'s |firstObject|()
lns3.scpt
if (tz's isKindOfClass:(current application's NSString)) as boolean then
lns3.scpt
if (current application's NSTimeZone's knownTimeZoneNames()'s containsObject:tz) as boolean then
lns3.scpt
set tz to current application's NSTimeZone's timeZoneWithName:tz
lns3.scpt
else -- assume it's already a time zone
lns3.scpt
end modify zone
lns3.scpt
on modify recurrence event theEvent event frequency theFreq event interval interv repeats for repeatCt : missing value repeats until endingDate : missing value
lns3.scpt
if theFreq = do daily then
lns3.scpt
set theFreq to 0
lns3.scpt
else if theFreq = do weekly then
lns3.scpt
set theFreq to 1
lns3.scpt
else if theFreq = do monthly then
lns3.scpt
set theFreq to 2
lns3.scpt
else if theFreq = do yearly then
lns3.scpt
set theFreq to 3
lns3.scpt
error "Invalid frequency parameter"
lns3.scpt
if endingDate is missing value then
lns3.scpt
set recurrEnd to current application's EKRecurrenceEnd's recurrenceEndWithOccurrenceCount:repeatCt
lns3.scpt
set recurrEnd to current application's EKRecurrenceEnd's recurrenceEndWithEndDate:endingDate
lns3.scpt
set recurrRule to current application's EKRecurrenceRule's alloc()'s initRecurrenceWithFrequency:theFreq interval:interv |end|:recurrEnd
lns3.scpt
stop recurrence event theEvent
lns3.scpt
theEvent's addRecurrenceRule:recurrRule
lns3.scpt
end modify recurrence
lns3.scpt
on stop recurrence event theEvent
lns3.scpt
if theEvent's hasRecurrenceRules() as boolean then
lns3.scpt
set theRules to theEvent's |recurrenceRules|()
lns3.scpt
if (count of theRules) > 0 then theEvent's removeRecurrenceRule:(item 1 of theRules)
lns3.scpt
end stop recurrence
lns3.scpt
on store event event theEvent event store theStore future events futureFlag : true
lns3.scpt
set {theResult, theError} to theStore's saveEvent:theEvent span:futureFlag commit:true |error|:(reference)
lns3.scpt
if not theResult as boolean then error (theError's |localizedDescription|() as text)
lns3.scpt
end store event
lns3.scpt
on event identifier for event theEvent
lns3.scpt
return theEvent's |calendarItemExternalIdentifier|() as text
lns3.scpt
end event identifier for
lns3.scpt
on event info for event theEvent
lns3.scpt
set theNull to current application's NSNull's |null|()
lns3.scpt
set theDict to current application's NSMutableDictionary's dictionaryWithObjects:{theNull, theNull, theNull, theNull, theNull, theNull, theNull} forKeys:{"event_summary", "event_time_zone", "event_location", "event_url", "event_description", "event_organizer", "event_original_date"}
lns3.scpt
theDict's setObject:(theEvent's calendar()'s title()) forKey:"calendar_name"
lns3.scpt
set theResult to (theEvent's calendar()'s |type|()) as integer
lns3.scpt
theDict's setObject:(item (theResult + 1) of {"local", "cloud", "Exchange", "subscription", "birthday"}) forKey:"calendar_type"
lns3.scpt
set theResult to (theEvent's title())
lns3.scpt
if theResult is not missing value then theDict's setObject:theResult forKey:"event_summary"
lns3.scpt
theDict's setObject:(theEvent's |calendarItemExternalIdentifier|()) forKey:"event_external_ID"
lns3.scpt
theDict's setObject:(theEvent's |startDate|()) forKey:"event_start_date"
lns3.scpt
theDict's setObject:(theEvent's |endDate|()) forKey:"event_end_date"
lns3.scpt
theDict's setObject:(theEvent's |isAllDay|()) forKey:"all_day"
lns3.scpt
set tz to (theEvent's timeZone())
lns3.scpt
if tz is not missing value then theDict's setObject:(tz's |name|()) forKey:"event_time_zone"
lns3.scpt
set theResult to (theEvent's location())
lns3.scpt
if theResult is not missing value then theDict's setObject:theResult forKey:"event_location"
lns3.scpt
set theURL to (theEvent's |URL|())
lns3.scpt
if theURL is not missing value then theDict's setObject:(theURL's |absoluteString|()) forKey:"event_url"
lns3.scpt
set theResult to (theEvent's |hasNotes|()) as boolean
lns3.scpt
if theResult then
lns3.scpt
set theResult to (theEvent's notes())
lns3.scpt
if theResult is not missing value then theDict's setObject:theResult forKey:"event_description"
lns3.scpt
set theAttendees to theEvent's |hasAttendees|()
lns3.scpt
if theAttendees as boolean then
lns3.scpt