Re: can I do this better?
Re: can I do this better?
- Subject: Re: can I do this better?
- From: Nigel Garvey <email@hidden>
- Date: Thu, 13 Jun 2002 16:00:33 +0100
Ric Phillips wrote on Thu, 13 Jun 2002 11:43:07 +1000:
>
On 13/6/02 3:47 AM, "garrett" <email@hidden> wrote:
>
>
> hey!
>
>
>
> I wrote this little routine to trim off any trailing or beginning spaces
>
or
>
> returns. would any of u pros do it differently or better? if so, how and
>
> why?
>
>
>
>
Well, a great deal depends on what you consider to be 'better'. For some
>
that is purely a matter of speed, for others readability of the source - and
>
then there is memory usage, and / or just plain elegance!
on trimText(s)
if (count s) is 0 then return s
set b to 1
repeat until character b of s > space
set b to b + 1
end repeat
set e to -1
repeat until character e of s > space
set e to e - 1
end repeat
return text b thru e of s
end trimText
NG
_______________________________________________
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.