• 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: Algorithms in Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Algorithms in Applescript


  • Subject: Re: Algorithms in Applescript
  • From: Tom Robinson <email@hidden>
  • Date: Mon, 30 Mar 2015 18:03:51 +1300

I'm interested in the 2 examples you shared, does seem simpler than the old methods.

But when I run either from Script Editor I receive:  'error "NSString doesn’t understand the “stringWithString_” message." number -1708 from NSString'

Am I missing something?

Cheers


On 2015-03-26, at 13:50, Shane Stanley <email@hidden> wrote:

capString("Frédéric Fromentin")
on capString(aString)
set theString to current application's NSString's stringWithString:aString
return (theString's uppercaseString()) as text
end capString

There's new stuff for them here, and the understandable first reaction will probably be something along the lines of, "Do I really need something else to think about?"

But consider a newcomer, and these two bits of code:

on replaceText(theString, theFind, theReplace)
considering case
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {theFind}
set theBits to text items of theString
set AppleScript's text item delimiters to {theReplace}
set theString to theBits as string
set AppleScript's text item delimiters to saveTID
end considering
return theString
end replaceText

And:

on replaceText(theString, theFind, theReplace)
set theNSString to current application's NSString's stringWithString:theString
set theNSString to theNSString's stringByReplacingOccurrencesOfString:theFind withString:theReplace
return theNSString as text
end replaceText

 _______________________________________________
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: Algorithms in Applescript
      • From: Shane Stanley <email@hidden>
References: 
 >Algorithms in Applescript (From: Jean-Christophe Helary <email@hidden>)
 >Re: Algorithms in Applescript (From: Christopher Stone <email@hidden>)
 >Re: Algorithms in Applescript (From: Shane Stanley <email@hidden>)
 >Re: Algorithms in Applescript (From: Christopher Stone <email@hidden>)
 >Re: Algorithms in Applescript (From: Shane Stanley <email@hidden>)
 >Re: Algorithms in Applescript (From: "Stockly, Ed" <email@hidden>)
 >Re: Algorithms in Applescript (From: Shane Stanley <email@hidden>)
 >Re: Algorithms in Applescript (From: "Stockly, Ed" <email@hidden>)
 >Re: Algorithms in Applescript (From: Shane Stanley <email@hidden>)
 >Re: Algorithms in Applescript (From: "Stockly, Ed" <email@hidden>)
 >Re: Algorithms in Applescript (From: Shane Stanley <email@hidden>)
 >Re: Algorithms in Applescript (From: "Stockly, Ed" <email@hidden>)
 >Re: Algorithms in Applescript (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: System Preference/Security & Privacy "Feature"
  • Next by Date: Re: Algorithms in Applescript
  • Previous by thread: Re: Algorithms in Applescript
  • Next by thread: Re: Algorithms in Applescript
  • Index(es):
    • Date
    • Thread