Repeat until (0r "while") not working

Sivakatirswami katir at hindu.org
Sat Aug 13 01:29:56 EDT 2005


Dave wins the prize for spotting my goof... I did have earlier in the  
handler (duh...)

   set the linedelimiter to "\"

So, I learned something, besides the several variations offered...

I moved the empty line cleanup outside the handler to a function:

main handler:

     put deleteEmptyLines(fld "transcript") into tFinalTranscript



function deleteEmptyLines tTranscript
   repeat while ((line 1 of tTranscript) is empty)
   delete line 1 of tTranscript
end repeat

repeat until ((the last line of tTranscript) is not empty)
   delete the last line of  tTranscript
end repeat

return tTranscript

end deleteEmptyLines

Interesting... even though the linedelimiter in the main handler is  
set to  "\"

Since the functions are independent... they respect CR as the line  
delimiter... and it works without having to reset the line delimiter  
in the main handler.

My goodness, how often I have in my scripts, changed delimiters mid- 
handler... when probably I should be doing the "LISP" thing that we  
see here from time to time, and breaking out these routines into  
discreet functions.

Thanks

Sivakatirswami





On Aug 09, 2005, at 10:44 PM, Dave Cragg wrote:

> On 10 Aug 2005, at 02:17, Sivakatirswami wrote:
>
>
>> I'm missing something very simple here,
>>
>> Goal: delete empty lines beginning and end of text chunk
>>
>> ---------------
>>
>> put fld "transcript" into tFinalTranscript
>>
>> # clean up extra lines at beginning and end
>>
>> repeat while ((line 1 of tFinalTranscript) is empty)
>>   delete line 1 of tFinalTranscript
>> end repeat
>>
>
> This part works here, with or without the parentheses.
>
> Thoughts:
> Are the leading lines really empty? For example, you don't have a  
> crlf there instead of a normal return. Or possibly you have set a  
> different lineDelimiter.
>
>
>
>>
>> repeat until ((the last line of tFinalTranscript) is not empty)
>>   delete the last line of  tFinalTranscript
>> end repeat
>>
>
> This may not do what you expect if the last char is a return.  
> Although it displays as though there is a blank line, Rev will  
> consider the last line to be the line before the final return. You  
> could add this after the second loop:
>
>   if char -1 of tFinalTranscript is return then delete char -1 of  
> tFinalTranscript
>
>
>
> Cheers
> Dave
> _______________________________________________
> 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