Finding items in a list of property lists

This may sound like a weird use for a list but I have found my self in need of a solution to this problem.

I have a list that contains property lists for keys in our software instead of iterating through all the items I was hoping there was a way to make this more efficient.

Example List:


set keyList to {
	(key:"0",row:4,position:6),
	(key:"1",row:3,position:6),
	(key:"2",row:3,position:7),
	(key:"3",row:3,position:8,special:true),
	(key:"+",row:0,position:1,special:true),
	(key:"-",row:1,position:1,special:true),
	(key:"/",row:2,position:1,special:true)
}

I would like to be able to do something like this but I’ve tried a number of ways with no effect and im not even sure it is possible.


repeat with each item in keyList where the property of special is true
	// do something here
end repeat

Any help here would be awesome!

Thank you,
Kyle

You’re on the right track. This should do the trick for you:

repeat with each item of each item of keyList where special of each
	put it -- or do something more interesting with it
end repeat

Yes, currently you need “each item of” twice – it’s sort of a matter of SenseTalk’s right hand not knowing what its left hand is doing. Hopefully one of these days it will get smarter. You could also say “where special of each is true” but that would be redundant. If something is true then it’s true – asking if it’s true will also return true, but then you have to decide where to stop: “true is true is true is true” is also true. :wink:

Thank you that work perfectly, I felt like I needed to use the item but was unable to get the syntax down.