trimming ?

J. Landman Gay jacque at hyperactivesw.com
Tue Aug 20 12:18:00 EDT 2002


Dave Cragg <dcragg at lacscentre.co.uk> wrote:
> 
> At 12:03 pm +0200 20/8/02, Sylvain Le Gourriérec wrote:
>>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

Another variation I use:

function trim theText
   repeat for each word w in theText
     put w & space after temp
   end repeat
   delete last char of temp
   return temp
end trim


-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the Use-livecode mailing list