Text case changing

Jim Hurley jhurley at infostations.com
Thu Jun 3 11:32:37 EDT 2004


>
>Message: 13
>Date: Wed, 2 Jun 2004 21:44:05 -0700
>From: Bill Vlahos <bvlahos at mac.com>
>Subject: Text case changing
>To: How to use Revolution <use-revolution at lists.runrev.com>
>Message-ID: <A46FA19E-B518-11D8-8727-0003936A2C42 at mac.com>
>Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>Revolution has the toUpper and toLower command which will convert an
>entire string. Is there something similar for capitalizing just the
>first letter as a built in function? I've come up with something that
>works but seems kind of hokey. Does anyone have a more elegant solution
>for this?
>
>Just to make life a little more complicated, there are some names like
>O'Malley or MacKeif or McBeth where it isn't just the first character.
>My application does not have to deal with these situations but a
>general solution would.
>
>Bill Vlahos
>


Bill,

The script below is something I have used in the past with a database 
containing 32,000 records. It won't catch everything. It is very 
quick.

Jim


on TitleCase
   ask "What field?"
   if it is empty then exit mouseUp
   put field it into tList
   put toLower(tList) into tList
   put space & tab & "-" & "'" &comma & return into tDelims
   put space into tLastChar
   repeat for each char tChar in tList
     if tLastChar is in tDelims then
       put toUpper(tChar) after results
       put tChar into tLastChar
     else
       put tChar after results
       put tChar into tLastChar
     end if
   end repeat
   repeat for each word tWord in tList
     if char 1 to 3 of tWord = "mac" then
       put "Mac" & toUpper(char 4 of tWord)&toLower(char 5 to 20 of 
tWord) into tWord
       put tWord
     end if
   end repeat
   put results into field "myField"
end TitleCase


More information about the use-livecode mailing list