How trim?

Mark Smith mark at maseurope.net
Sat Oct 22 14:22:11 EDT 2005


I got these:

to strip leading spaces

function trimL aString
    return char offset(word 1 of aString, aString) to -1 of aString
end trimL

to strip trailing spaces

function trimR aString
   return  char 1 to  length(word 1 to -1 of aString) + (offset(word  
1 of aString, aString) - 1) of aString
end trimR

surprisingly ugly for transcript....


Mark





On 22 Oct 2005, at 16:04, Bob Warren wrote:

> Thanks a lot, Marcus.
> The double trim is easy as you say, but I would never have guessed it.
> However, by what I see from Alex Tweedly's first ideas about left  
> and right trims, these may not be so trivial. Any ideas about  
> simple solutions for these cases?
>
> Alex:
>
> I couldn't seem to make your first suggestions for L and R trims  
> work. Would you mind spelling out some example routines for me?
>
> Best,
> Bob
>
> ------------------------------------------------
> >Hello,
>
> >With revolution this is even easier than Basic, all you need to do  
> is:
>
> >put word 1 to -1 of "        The cat sat under the mat.         "
>
> >This will put "The cat sat under the mat." into message.
>
> >Regards,
>
> >Marcus
>
> >Software Developer
> >Runtime Revolution
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list