• 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: Yvan KOENIG <email@hidden>
  • Date: Fri, 06 Jan 2017 11:14:40 +0100


Le 5 janv. 2017 à 22:21, debt <email@hidden> a écrit :



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

Good point. Even after cleaning my ASObjC code, yours is faster.

Yours:
use AppleScript version "2.5" -- Mac OS 10.11 (El Capitan) or later.
use framework "Foundation"
use scripting additions

set startDate to current application's NSDate's |date|()
repeat 1000 times


tell application "Contacts" to tell group "Famille" 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
solicitor_list
end repeat

set timeDiff to startDate's timeIntervalSinceNow()
display dialog "That took " & (-timeDiff as real) & " seconds."
--> "That took 7,900698006153 seconds."


My cleaned one:
-------------------------------------------------------------------------------------------
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions

on cleanList:theList
set theArray to current application's NSMutableArray's arrayWithArray:theList
set unionOfArrays to (theArray's valueForKeyPath:"@unionOfArrays.self")
return unionOfArrays as list
end cleanList:


set startDate to current application's NSDate's |date|()
repeat 1000 times


tell application "Contacts"
tell group "Famille"
set phoneNumList to value of every phone of every person
end tell
end tell
set phoneNumList to its cleanList:phoneNumList


end repeat

set timeDiff to startDate's timeIntervalSinceNow()
display dialog "That took " & (-timeDiff as real) & " seconds."
--> "That took 8,027648031712 seconds."
-------------------------------------------------------------------------------------------

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 11:13:39




 _______________________________________________
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>
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>)
 >Re: Creating a list of numbers from a Contacts group (From: debt <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