• 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 14:15:20 +0100


Le 6 janv. 2017 à 11:14, Yvan KOENIG <email@hidden> a écrit :



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."
-------------------------------------------------------------------------------------------

I discovered that theArray had no need to be defined as mutable.

Replacing the handler by :

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

fasten slightly the script. -->  "That took 7,940750956535 seconds."

Of course the really interesting feature is that the instruction :

return (theArray's valueForKeyPath:"@unionOfArrays.self") as list

drop the empty lists with no other action. I was so surprised when I discovered that that I double checked that there was really empty lists in the original datas.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 14:14:30





 _______________________________________________
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

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>)
 >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