Converting to title case

James Hurley jhurley0305 at
Wed Aug 25 14:37:14 EDT 2010

I do a lot of election database work for local candidates. The DB  
comes from the county and is quite large. All the data is upper case  
which I find ugly on a campaign mailer label.

I have a stack (below) which converts a text field to Title Case   
which, for my purposes, is a capital letter after every appearance of  
a white space. I know there are some sneaky ascii codes out there that  
masquerade as white spaced. Are there some I should consider besides:

(I handle proper names like MacDonald, O'Connors separately when  
constructing label data for campaign mailers. Within RunRev I  
construct a Google search

  put "" & tLastName into tName
  get url  tName

and then parse "it" for capitalization of the name in question. A  
little slow, but it works well enough. God, I love RunRev's  

So any suggestions for sneaky white spaces to look out for?


on mouseUp
    put field 2 into tList
    put toLower(tList) into tList

    --Define white spaces
    put tab,return,cr,enter,space into tWhiteSpaces
    --Are these all I should look out for?
    repeat for each item tItem in tWhiteSpaces
       put true into aWhiteSpace[tItem]
    end repeat

    --Insert capital after white space
    put space into tPrevious
    repeat for each char tChar in tList
          case aWhiteSpace[tPrevious]
             put toUpper(tChar)  after results
             put tChar after results
       end switch
       put tChar into tPrevious
    end repeat

    put results into field 3
end mouseUp

More information about the Use-livecode mailing list