• 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: Another address book question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another address book question


  • Subject: Re: Another address book question
  • From: Paul Berkowitz <email@hidden>
  • Date: Tue, 17 Feb 2004 15:31:59 -0800

On 2/17/04 1:51 PM, "Michelle Steiner" <email@hidden> wrote:

> Why doesn't this work?
>
> tell application "Address Book"
> set this_person to person "Michelle Steiner"
> set persons_email to email of this_person
> email of items of persons_email whose label is "home" --this line
> fails
> end tell
>
> "Can't get email of {email 1 of person id
> \"8C984718-C1E9-11D6-826B-000A27835F42:ABPerson\" of application
> \"Address Book\", email 2 of person id
> \"8C984718-C1E9-11D6-826B-000A27835F42:ABPerson\" of application
> \"Address Book\"}."
>
> The dictionary says "email: by numeric index, before/after another
> element, as a range of elements, satisfying a test, by ID" (I inserted
> the colon for clarity.)
>
> So, why doesn't it satisfy the test?

What does 'of items of persons_email ' mean here? There's never any point
to getting 'items of aList' -- you just get the same list again.

(Also, email is an element, not a property, of person, so 'email of
this_person' shouldn't really work, but it gets interpreted as the plural
'emails' so that's OK.)

As we all know all too well, 'whose' filters don't work on AppleScript
lists. This is, IMO, the biggest lack in ApleScript. So you can't resolve a
list, then try to use a whose filter on it. Even the more readble

every email of persons_email whose label is "home"

errors for that reason (although it's a mighty peculiar error here: Can't
get {} whose label = "home".

You need to operate the filter on the application command itself, not on a
resolved list:

tell application "Address Book"
set this_person to person " Michelle Steiner"
set home_email to every email of this_person whose label is "home"
end tell
--> {email 2 of person id "8C984718-C1E9-11D6-826B-000A27835F42:ABPerson\"
of application \"Address Book\"} ... etc.

or, somewhat more usefully


tell application "Address Book"
set this_person to person " Michelle Steiner"
set home_email to value of every email of this_person whose label is
"home"
end tell
--> {"email@hidden"} -- or whichever it is
--
Paul Berkowitz
_______________________________________________
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.

  • Follow-Ups:
    • Re: Another address book question
      • From: Michelle Steiner <email@hidden>
References: 
 >Another address book question (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Simple? Tell FMP to open a database?
  • Next by Date: OT: Entourage send Meeting invite Outlook on PC
  • Previous by thread: Another address book question
  • Next by thread: Re: Another address book question
  • Index(es):
    • Date
    • Thread