problem of event in ical

hello, i have a problem to count and choose events in ical


repeat with cetEvenementFerie in ((every event of calendrierJoursFeries) whose ((start date ≥ x1 and (start date ≤ x2))))

it count only events which don’t repeat

how to count every event ?

sorry for my poor english
Thank

Model: g4 mdd
Browser: Safari 417.9.3
Operating System: Mac OS X (10.4)

Repeating events are different because their start date is still the original start date from the first time the event was entered. Then they have a “recurrence” string that tells iCal when to repeat the event, based on the original start date and the interval between repetitions.

You will have to get every event that has a recurrence string defined and add those to the ones you get with the script you already have.

Hope that helps.

(and your English is fine, we’re international-friendly here at MacScripter! :slight_smile:

I have some repeating medical events (blood tests every 6 weeks) in addition to regular appointments (every 8 weeks for one thing and every 16 for another - Life in the fast late at age 69). This is how I recover that data, sort it, and present it with Growl, but you could present it any other way.


-- This script shows upcoming Medical or Dental appointments.
-- The script uses Growl to display the result.

set today to (current date)
set sDate to short date string of today as string
set wDay to weekday of today
--  Build the Medical List "MAppt" {name, date, name, date, ...}
tell application "iCal"
	close window 1
	set MCals to every calendar whose title contains "Medical"
	set mCal to item 1 of MCals
	set toGo to {}
	-- Collect the date/name list as mdCal
	set mCount to count events of mCal
	set mdEvent to {}
	set mdDate to {}
	repeat with n from 1 to mCount
		-- Get summary and start date of each [THIS IS THE PART THAT GETS THE REPEAT]
		tell event n of mCal
			set {anEvent, aDate} to {summary of it, start date of it}
			if anEvent contains "(" then
				set paren to offset of "(" in anEvent
				set Rep to character (paren + 1) of anEvent
				tell (Rep * weeks) to set aDate to today + (it - ((today - aDate) mod it))
			end if
		end tell
		if ((aDate) - today) > 0 then
			set end of mdEvent to anEvent
			set end of mdDate to aDate
		end if
	end repeat
	--	quit
end tell
-- Sort Events and Dates by date
Sort_items(mdDate, mdEvent)

-- set up the Growl notification
set r to return
set sp to space
set m to ASCII character 240
set msg to ""
repeat with k from 1 to count mdDate
	set msg to (msg & r & m & sp & sp & item k of mdEvent & " on " & r & item k of mdDate as string) & r
end repeat


Growl_It("Medical & Dental Appointments" & return & "       As of " & wDay & space & sDate & return & "-------------------------", msg)
--tell application "iCal" to quit

-- Handlers --
on Growl_It(gTitle, gMessage)
	tell application "GrowlHelperApp"
		notify with name "MedDent" title gTitle description gMessage application name "MiCal" icon of application "iCal" with sticky
	end tell
end Growl_It

to Sort_items(sortList, SecondList) -- an adaptation of a script by Kai
	tell (count sortList) to repeat with i from (it - 1) to 1 by -1
		set s to sortList's item i
		set r to SecondList's item i
		repeat with i from (i + 1) to it
			tell sortList's item i to if s > it then
				set sortList's item (i - 1) to it
				set SecondList's item (i - 1) to SecondList's item i
			else
				set sortList's item (i - 1) to s
				set SecondList's item (i - 1) to r
				exit repeat
			end if
		end repeat
		if it is i and s > sortList's end then
			set sortList's item it to s
			set SecondList's item it to r
		end if
	end repeat
end Sort_items