I wrote:
> on StripLeadingWhiteSpace(MessageBody)
> 
>     set paragraphList to the paragraphs of MessageBody
>     repeat while paragraphList is not {}
>         if isWhiteSpace(item 1 of paragraphList) then
>             set paragraphList to rest of paragraphList
>         end if
>     end repeat
> 
>     return ListAsString(paragraphList, return)
> 
> end StripLeadingWhiteSpace

 Underscoring what a PITA AppleScript is, the loop above (a hasty change
to avoid an error) will clearly not terminate. Here is the modified
version which will terminate.

on StripLeadingWhiteSpace(MessageBody)
        
        set paragraphList to the paragraphs of MessageBody
        repeat while paragraphList is not {}
                if isWhiteSpace(item 1 of paragraphList) then
                        set paragraphList to rest of paragraphList
                else
                        exit repeat
                end if
        end repeat
        
        return ListAsString(paragraphList, return)
        
end StripLeadingWhiteSpace

If anyone knows of a better way to do this (other than giving up
AppleScript and using Python), please let me know.

jwq

___________________________________________________________________________
To unsubscribe send a mail message with a SUBJECT line of "unsubscribe" to
<[EMAIL PROTECTED]>  or  <[EMAIL PROTECTED]>

Reply via email to