Title Case

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

Title Case

Post by sandybassett »

I had this is another thread but think I should start a new one for it.
Craig, I think you are telling me that there is no TitleCase function in LiveCode and I had better resurrect an ancient coding technique into LC language to roll my own. Maybe something like-separate chunks delineated by space, put each chunk toLower, get 1st char of each chunk & put toUpper, merge chunks back together. If that's right, since I would be using this on most all input fields, I should make it a function and put it somewhere? so as to have it available for including in every stack I create? N'est pas?

Before spending some time on this, am I on the right track or is there some other way? Thanks for the help.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Title Case

Post by Klaus »

Hi Sandy,

pardon my ignorance, but what does a "TitleCase" "function" do? 8-)


Best

Klaus
sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

Re: Title Case

Post by sandybassett »

TitleCase (sometimes called Mixed Case) puts the first letter of each word in uppercase and the rest of the word in lowercase. Very convenient for input of names of people, addresses, cities, books, etc especially when the user is low on grammatical skills and can just type everything in lowercase and have the program 'fix it' for him.
Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Title Case

Post by Dixie »

Then look at 'toUpper' in the dictionary...
for example...

Code: Select all

on mouseUp
   put toLower( fld 1) into fld 1
   repeat with count = 1 to the number of words of fld 1
      put toUpper( char 1 of word count of fld 1) into char 1 of word count of fld 1
   end repeat
end mouseUp
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Title Case

Post by Klaus »

EX-ACTLY! :-)
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Title Case

Post by FourthWorld »

It may be helpful to add a list of words to leave as lower-case, like "of", "an", and", etc.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

Re: Title Case

Post by sandybassett »

OK thanks guys; I'll try Dixie's code first and adapt from there if necessary. So my 2nd question was about best practices I guess. Since you can drag any existing stack into the one you're working on, would you keep various scripts in a master file and copy the desired ones to the current stack, or is there a better way to avoid re-inventing the wheel with every program?
Post Reply