TRIM command?

Sarah Reichelt sarah.reichelt at gmail.com
Thu May 18 17:05:55 EDT 2006


On 5/19/06, mfstuart at cox.net <mfstuart at cox.net> wrote:
> Hi all,
>
> Is there a RunRev TRIM command? To remove beginning and/or trailing spaces.
> If there is, I can't find it.
> If there isn't, how would I script the function for this?

There was a lot of discussion about this a few months ago, so an
archive search might prove useful. However here are a couple of
suggestions to get you going:

If the extra white spaces are only at the beginning & end of the text
i.e. not between words, then this one-liner will do:

put word 1 to -1 of myText into myText

If there could be extra spaces between words, then this is what I use:

put empty into myTrimmedText
repeat for each word w in myText
  put w & space after myTrimmedText
end repeat
delete last char of myTrimmedText  -- get rid of last space

HTH,
Sarah



More information about the use-livecode mailing list