• 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: Creating a list of numbers from a Contacts group
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a list of numbers from a Contacts group


  • Subject: Re: Creating a list of numbers from a Contacts group
  • From: debt <email@hidden>
  • Date: Thu, 05 Jan 2017 13:21:04 -0800

You may shorten your code :
-------------------------------------------------------------------------------------------
tell application "Contacts"
tell group "Famille"
set phoneNumList to value of every phone of every person
end tell
end tell

set tid to text item delimiters
set text item delimiters to {return}
set phoneNumList to (phoneNumList as text)
repeat while phoneNumList contains return & return
set text item delimiters to {return & return}
set phoneNumList to every text item of phoneNumList
set text item delimiters to {return}
set phoneNumList to phoneNumList as text
end repeat
set text item delimiters to tid
if last character of phoneNumList is return then set phoneNumList to text 1 thru -2 of phoneNumList

set phoneNumList to paragraphs of phoneNumList
—————————————————————————————————————————————

I’m sure I’m missing something here, but why not do something like this instead?  It’s shorter, you’re not changing the delimiters, and not dealing with paragraphs and characters.

tell application "Contacts" to tell group "Solicitors" to set phone_num_list to value of every phone of every person

set solicitor_list to {}
repeat with each_contact in my phone_num_list
repeat with each_phone_num in each_contact
set solicitor_list to solicitor_list & each_phone_num
end repeat
end repeat

Marc
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Creating a list of numbers from a Contacts group
      • From: Yvan KOENIG <email@hidden>
    • Re: Creating a list of numbers from a Contacts group
      • From: Steve Mills <email@hidden>
References: 
 >Re: Creating a list of numbers from a Contacts group (From: Steve Mills <email@hidden>)
 >Re: Creating a list of numbers from a Contacts group (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Creating a list of numbers from a Contacts group
  • Next by Date: Re: Creating a list of numbers from a Contacts group
  • Previous by thread: Re: Creating a list of numbers from a Contacts group
  • Next by thread: Re: Creating a list of numbers from a Contacts group
  • Index(es):
    • Date
    • Thread