• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Efficiently using whose on Address Book users
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Efficiently using whose on Address Book users


  • Subject: Re: Efficiently using whose on Address Book users
  • From: Lachlan Deck <email@hidden>
  • Date: Mon, 23 Feb 2004 15:36:52 +1100

Hi there,

On Monday, February 23, 2004, at 12:16 PM, Jeff Porten wrote:

I'm writing a script that I want to act differently based on whether a user is in the Address Book.

Elaborating on Paul's example...

set theName to getNameFromEmail(senderAddress) as string
if (theName is not null) then
tell app "Address Book"
set thePerson to person theName
...
end tell
end if

-- returns the name of person who has an email address -- that is equal to anEmail
on getNameFromEmail(anEmail)
tell application "Address Book"
try
return name of first person ,
whose value of every email contains anEmail
end try
return null
end tell
end getNameFromEmail

On Monday, February 23, 2004, at 12:38 PM Paul Berkowitz wrote:

It's only where you want to go looking for "silcom.com" or
"berkowit" that you need a loop.

And even then - it need not be inefficient (i.e., in 10s of seconds which occurs when you repeatedly request individual data from another app as you found. If you get the whole list at once - then the time taken to search through the resulting list of data is quite brief in comparison.)

-- returns a list of email addresses containing the substring aString
on getEveryEmailContaining(aString)
tell application "Address Book"
set theList to {}
repeat with aValue in (value of every email of every person) as list
if ((aValue as string) contains aString) then
set the end of theList to (aValue as string)
end if
end repeat
return theList
end tell
end getEveryEmailContaining

with regards,

--
Lachlan Deck
email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Efficiently using whose on Address Book users (From: Jeff Porten <email@hidden>)

  • Prev by Date: Re: Trying to script the creation of a script
  • Next by Date: Re: Date Modified
  • Previous by thread: Re: Efficiently using whose on Address Book users
  • Next by thread: iTunes shared-song artwork?!
  • Index(es):
    • Date
    • Thread