• 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: Missing ampersand
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing ampersand


  • Subject: Re: Missing ampersand
  • From: Jeremy Roussak <email@hidden>
  • Date: Tue, 28 Mar 2017 09:52:49 +0100

Thank you all for a very interesting discussion. Funny what a request for help with a trivial problem can lead to; and gratifying to have such helpful people around.


Jeremy Roussak
email@hidden



On 25 Mar 2017, at 10:56, Shane Stanley <email@hidden> wrote:

On 25 Mar 2017, at 10:33 am, Christopher Stone <email@hidden> wrote:

AppleScriptObjC works quite well for this as well and returns the same result.  (This is equivalent to using AppleScript's text item delimiters.)

Yes, although the equivalent to your other handlers, which split on any white space characters including line breaks, would be:

use framework "Foundation"
use scripting additions

set theString to "eric v smith & jones"

set stringComponentList to my splitOnAnySpace:theString

on splitOnAnySpace:someText -- free to a good home
set theString to current application's NSString's stringWithString:someText
set theList to theString's componentsSeparatedByCharactersInSet:(current application's NSCharacterSet's whitespaceAndNewlineCharacterSet())
return theList as list
end splitOnAnySpace:

Or roughly:

use framework "Foundation"
use scripting additions

set theString to "eric v smith & jones"

set stringComponentList to my splitString:theString atCharactersInString:(linefeed & return & tab & space)

on splitString:someText atCharactersInString:stringOfChars -- free to a good home
set theString to current application's NSString's stringWithString:someText
set theList to theString's componentsSeparatedByCharactersInSet:(current application's NSCharacterSet's characterSetWithCharactersInString:stringOfChars)
return theList as list
end splitString:atCharactersInString:

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>

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: 
 >Missing ampersand (From: Jeremy Roussak <email@hidden>)
 >Re: Missing ampersand (From: Yvan KOENIG <email@hidden>)
 >Re: Missing ampersand (From: Jeremy Roussak <email@hidden>)
 >Re: Missing ampersand (From: Christopher Stone <email@hidden>)
 >Re: Missing ampersand (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Application Indexes
  • Next by Date: Re: Sierra mail problem
  • Previous by thread: Re: Missing ampersand
  • Next by thread: Detect when an app is crashed
  • Index(es):
    • Date
    • Thread