trimming ?

Dave Cragg dcragg at lacscentre.co.uk
Tue Aug 20 06:17:01 EDT 2002


At 12:03 pm +0200 20/8/02, Sylvain Le Gourriérec wrote:
>Hello,
>
>how can I trim spaces of a textfield, i.e. convert any " my text "
>into "my text"?
>
>Does a function exist or do I need to build one?

You need to build one.

This is what I use:

function trimText pText
  put cr & tab & space into tTrimChars
  repeat while char 1 of pText is in tTrimChars
    delete char 1 of pText
  end repeat
  repeat while char -1 of pText is in tTrimChars
    delete char -1 of pText
  end repeat
  return pText
end trimText



More information about the use-livecode mailing list