• 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: 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.

References: 
 >Re: can I do this better? (From: Matthew Stuckwisch <email@hidden>)

  • Prev by Date: Easy, i think, Mount Volume Question?
  • Next by Date: Re: Pasting Poscript into a Quark box
  • Previous by thread: Re: can I do this better?
  • Next by thread: Mac OS 9.2.2 - where did Keychain Scripting go?
  • Index(es):
    • Date
    • Thread