• 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: cutting multiple sections from a string?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cutting multiple sections from a string?


  • Subject: Re: cutting multiple sections from a string?
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 05 Sep 2013 15:06:28 +1000

On 04/09/2013, at 3:05 AM, Alex Hall <email@hidden> wrote:

set {startCut, endCut} to {item 1 of cut, item 2 of cut}

If there are only ever two items, you can use:

set {startCut, endCut} to cut

 set newStr to (characters 1 through (startCut - 1) of newStr) as string

What you're doing there is making a list of characters, and then coercing them to a string. That's not only wasteful, but it's also dependent the value of AppleScript's text item delimiters at the time -- something that makes it error prone. Instead, use the form:

if startCut > 1 then set newStr to text 1 through (startCut - 1) of newStr


-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: cutting multiple sections from a string? (From: Nigel Garvey <email@hidden>)
 >Re: cutting multiple sections from a string? (From: Alex Hall <email@hidden>)

  • Prev by Date: Re: [SPAM] cutting multiple sections from a string?
  • Next by Date: Re: cutting multiple sections from a string?
  • Previous by thread: Re: cutting multiple sections from a string?
  • Next by thread: Re: Rich text from an Outlook 2011 email message
  • Index(es):
    • Date
    • Thread