| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
on Tuesday, October 29, 2002, at 06:56 AM, Paul Skinner
<email@hidden> wrote:
On Tuesday, October 29, 2002, at 06:56 AM, Kai Edwards wrote:
---------------------------------------------------
set tid to text item delimiters
set l to {".", ",", "/", ":", tid}
set n to "this/might not.be a legal:name, then again, it could be."
set text item delimiters to l's item 1
repeat with i from 2 to count l
set {n, text item delimiters} to {(n as string)'s text items, l's item
i}
end repeat
set n to n as string
if n's length > 32 then set n to n's text 1 thru 32
n
---------------------------------------------------
Looping through only the smallest useful set is always the best option,
and your TIDs loop is tight! I like it.
Thanks, Paul.
TIDs avoided the need for character-by-character analysis, while the
manipulation of text, rather than list items, also helped to boost the
overall speed. (OMM, the above variation generally runs 9-10 times faster
than the original suggestion.)
Minimally this could be...
Unfortunately, that's just a little too minimal for my machines:
--> "this/might not.be a legal:name, "
I'm afraid that the TIDs also remain set to the last item in the list (":")
- which of course may produce unexpected results elsewhere.
(Tested on OS 8.1/AS 1.1.2, OS 9.1/AS 1.5.5)
Best wishes.
Kai
| References: | |
| >Re: Removing characters from a string (From: Kai Edwards <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.