Re: can I do this better?
Re: can I do this better?
- Subject: Re: can I do this better?
- From: Michelle Steiner <email@hidden>
- Date: Wed, 12 Jun 2002 13:55:53 -0700
Here's my solution; I did not check it for speed, but it traps both null
strings and strings that are spaces only.
--Michelle
to trimText(instring, direction)
if direction is in {1, -1} then
if instring is not "" then
try
set testList to text items of instring
if direction is -1 then set testList to reverse of the testList
repeat while the first item of the testList is " "
set the testList to the rest of the testList
end repeat
if direction is -1 then set testList to the reverse of the testList
return the testList as text
on error --traps for string of spaces only
return ""
end try
else
return instring --traps for null string
end if
else
display dialog "Use only 1 or -1 to indicate direction."
end if
end trimText
On Wednesday, June 12, 2002, at 01:01 PM, Matthew Stuckwisch wrote:
This one goes a little bit faster, I'll try to think of a faster one
later,
of course, has probably already the absolute most optimized one
already ;
-)
We're not human beings having a spiritual experience.
We're spiritual beings having a human experience.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.