Repeat until (0r "while") not working
Dick Kriesel
dick.kriesel at mail.com
Wed Aug 10 17:45:20 EDT 2005
On 8/9/05 7:36 PM, "Ken Ray" <kray at sonsothunder.com> wrote:
> On 8/9/05 8:17 PM, "Sivakatirswami" <katir at hindu.org> wrote:
>
>> I'm missing something very simple here,
>>
>> Goal: delete empty lines beginning and end of text chunk
>
> Try this:
>
> function trim pWhat
> local tRetVal
> get matchText(pWhat, "(?s)^\s*(.*?)\s*$", tRetVal)
> return tRetVal
> end trim
>
>
> Trims all forms of whitespace (CRs, spaces, tabs, etc.) from the beginning
> and end of a text chunk.
Or try the following if you want only to strip all occurrences of a
character, such as "return," from the beginning and/or ending of a string:
function strip pString,pSide,pChar
if pString is not empty then
put pString into tString
if pChar is empty then put return into tChar
else put pChar into tChar
switch pSide
case ""
case "both"
put strip(tString,"left",tChar) into tString
put strip(tString,"right",tChar) into tString
break
case "left"
repeat until char 1 of tString is not tChar
delete char 1 of tString
end repeat
break
case "right"
repeat until char -1 of tString is not tChar
delete char -1 of tString
end repeat
break
end switch
return tString
end if
end strip
More information about the use-livecode
mailing list