Converting to title case

James Hurley jhurley0305 at sbcglobal.net
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:
'
space
return
enter
tab

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

  put "http://www.google.com/search?q=" & 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  
versatility.)

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

JIm

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
       switch
          case aWhiteSpace[tPrevious]
             put toUpper(tChar)  after results
             break
          default
             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