• 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: Trim?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trim?


  • Subject: Re: Trim?
  • From: Nigel Garvey <email@hidden>
  • Date: Mon, 5 Aug 2002 02:25:30 +0100

Paul Skinner wrote on Sun, 4 Aug 2002 11:13:10 -0400:

>On Sunday, August 4, 2002, at 06:42 AM, Nigel Garvey wrote:

>> How about this version of yours?
>>
>> set inputText to " email@hidden 'This is a > string?' "
>> cleanSpaces(inputText)
>> -->"email@hidden 'This is a > string?'"
>>
>> on cleanSpaces(inputText)
>> set space2 to space & space
>> set inputText to space & inputText & space
>> repeat while inputText contains space2
>> set AppleScript's text item delimiters to space2
>> set tempS to text items of inputText
>> set AppleScript's text item delimiters to space
>> set inputText to tempS as text
>> end repeat
>> set AppleScript's text item delimiters to ""
>> return text 2 thru -2 of inputText
>> end cleanSpaces
>>
>> NG
>>
>
>Primo.
>
>This is the functional loop and nothing else. It loops only round
>( square root of (the length of the longest run of spaces) rounding up)
>times.

I think the loop executes once for each power of 2 up to and including
the lowest that contains the length of the longest run of spaces.
(There's probably a better way of expressing this. ;-))

0-1 spaces: 0 loops (2 ^ 0 = 1)
2 spaces: 1 loop (2 ^ 1 = 2)
3-4 spaces: 2 loops (2 ^ 2 = 4)
5-8 spaces: 3 loops (2 ^ 3 = 8)
9-16 spaces: 4 loops (2 ^ 4 = 16)
17-32 spaces: 5 loops (2 ^ 5 = 32)
etc.

Tested by inserting a beep into the loop. :-)

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: Misc Eudora questions
  • Next by Date: Re: Misc Eudora questions
  • Previous by thread: Re: Trim?
  • Next by thread: Log
  • Index(es):
    • Date
    • Thread