|
|
#1 |
|
Triple-A Player
Join Date: May 2004
Posts: 52
|
How to use nested Where Commands to filter in Applescript
The "where" or "whose" command is great for doing quick and easy searches in Applescript, for instance, the following script to search for the email of someone with a certain name:
Code:
tell application "Address Book" set thisContact to (get every person whose name is "Joe Schmo") if length of thisContact > 0 then return value of first item of email of thisContact else return "Not found." end if end tell Code:
set thisContact to the first item of (get every person where ¬
the value of the email of it contains "joe@schmoe.com")
Code:
set fromPerson to "Joe Schmo"
tell application "Address Book"
set allContacts to people
set resultsOfSearch to {}
set isMatch to false
repeat with thisContact in allContacts
if name of thisContact is fromPerson then
set end of resultsOfSearch to thisContact
set isMatch to true
exit repeat
end if
end repeat
if isMatch then
set fromPerson to the name of thisContact
return value of first item of email of thisContact
end if
end tell
Last edited by ephramz; 09-14-2004 at 12:57 AM. |
|
|
|
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|