Re: cutting multiple sections from a string?
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
|
_______________________________________________
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