• 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: can I do this better?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Mac OS 9.2.2 - where did Keychain Scripting go?
  • Next by Date: List Question: Can someone explain this to me?
  • Previous by thread: Re: can I do this better?
  • Next by thread: Re: can I do this better?
  • Index(es):
    • Date
    • Thread