• 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: Stan Cleveland <email@hidden>
  • Date: Thu, 05 Jan 2017 12:37:10 -0800

On Jan 5, 2017, at 11:50 AM, Steve Mills <email@hidden> wrote:

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.
Hi Steve,

Has's "List" library, part of his applescript-stdlib project will handle that for you:

use script "List"

set blah to {"one", "", "two"}
set nonNullItems to filter list blah using isNotNullString
--> {"one", "two"}

script isNotNullString
to filterItem(aValue)
return aValue is not ""
end filterItem
end script

Using a script object to define the filter is a unique approach and does add a few lines of code, but it's reusable and kept out of the way, much like a handler or subroutine.

My "wish" is that Apple would include has's libraries as part of the standard OS X installation. They are really quite nice and add valuable capabilities to the AS toolbox.

Regards,
Stan C.

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

  • 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