Function to Upper and Lower Case sentences

Bob Sneidar bobs at twft.com
Wed Dec 21 14:57:14 CST 2011


On Dec 21, 2011, at 12:43 PM, Sivakatirswami wrote:

> I have a need to take all caps input  and
> 
> 1) Lower case all but first letter of sentences
> 
> 2) Upper case words in a small dictionary I will provide to the function.
> 
> As anyone cooked up something like this already... if I just had 1) can manage 2)
> 
> Happy Holidays!
> 
> Om Shanti
> Sivakatirswami
> 
> Kauai Aadheenam
> 
> __________________________

function titleCase theText, forceIt    
    if forceIt is true then
        put tolower(theText) into theText
    end if
    
    repeat with theWordNum = 1 to the number of words of theText
        put toupper(char 1 of word theWordNum of theText) & \
                char 2 to -1 of word theWordNum of theText \
                into word theWordNum of theText
    end repeat

    return theText
end titleCase




More information about the use-livecode mailing list