Re: Creating a list of numbers from a Contacts group
Re: Creating a list of numbers from a Contacts group
- Subject: Re: Creating a list of numbers from a Contacts group
- From: Steve Mills <email@hidden>
- Date: Thu, 05 Jan 2017 19:50:34 +0000 (GMT)
On Jan 05, 2017, at 01:20 PM, debt <email@hidden> wrote:
On Jan 5, 2017, at 10:53 AM, Steve Mills <
email@hidden> wrote:
That's correct. "e" is the error string that resulting from the div by zero. He's just being a showoff. :) Here's a more AppleScripty way of doing it. It replaces the entire try/on error block:
set phoneNumList to phoneNumList as text
set text item delimiters to {","}
set phoneNumList to every text item of phoneNumList
I tried your version but it destroys the list, so Chris may actually be on to something with the try block. :)
Sorry, the delimiters were already set to a non-default value before I ran it, so it worked. If you really want to learn how to do this with AppleScript, experiment and don't use error message hacks (whose content can sure change on a whim of some future update) or Unix commands unless there really is no other way. This'll do it:
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 {return}
if last character of phoneNumList is return then set phoneNumList to text 1 thru -2 of phoneNumList
set phoneNumList to every text item of phoneNumList
set text item delimiters to tid
I really wish there was a way to filter lists directly in AppleScript. Like why can't this work:
set blah to {"one","","two"}
set blah to every item of blah where it is not ""
-->{"one","two"}
That would make this script so much shorter. Or even:
tell application "Contacts"
tell group "Family"
set phoneNumList to value of every phone of (every person whose phones is not {})
end tell
end tell
Sent from iCloud's ridiculous UI, so, sorry about the formatting
_______________________________________________
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