Whose condition with list

Hi All,

I’m writing a script for outlook to pull out certain calendar entries for me. I effectively want to give a list of calendar event IDs to exclude and get everything else.

set exclusionList to {32,33}
set calendarEvents to every calendar event of theCal whose id is not in exclusionList

This doesn’t return anything. Is it possible to use the where clause with this list?

I considered getting all calendar entries and then cycling through but it took a very long time to get all of the calendar entries out.


The whose clause doesn’t work with lists. So, the short answer is: NO.

This is not entirely true. More often than not, with a large number of elements, the whose clause will run much slower than a well-written repeat loop.

To achieve speed, you can use script objects. As in the following illustrative example without using Microsoft Outlook (because I don’t have it). Working with event IDs instead of events itself improves the speed as well.

set exclusionList to {32, 33}
set idsList to {1, 2, 32, 400, 13}

-- tell application "Microsoft Outlook"
---- set idsList to id of calendar events of theCal
-- end tell

my findMissingItems(idsList, exclusionList)

on findMissingItems(referenceList, testList)
	script o -- script object named "o"
		property refLst : referenceList
		property output : {}
	end script
	repeat with i from 1 to (count referenceList)
		set thisItem to item i of o's refLst
		if (thisItem is not in testList) then set end of o's output to thisItem
	end repeat
	return o's output
end findMissingItems