Uppercase text

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

Uppercase text

Post by sandybassett » Fri May 31, 2013 7:57 pm

I'm new to LiveCode but have coded for 30+ years. So I'm trying to learn the correct syntax for everything. How do I make a field (State) force all entry to uppercase? I've tried everything I can think of but don't have it right. It has to be something real easy. Thanks for the help.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Uppercase text

Post by Dixie » Fri May 31, 2013 8:07 pm

look at toUpper in the dictionary...

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Uppercase text

Post by FourthWorld » Fri May 31, 2013 8:09 pm

If you want to do this after input is done, this should work on most cases

Code: Select all

on closeField
   set the text of me to toUpper(the text of me)
end closeField
But if you want to do it in real-time as text is entered, you'll need to save and restore the selection:

Code: Select all

on textChanged
   put the selectedChunk into tSaveSel
   set the text of me to toUpper(the text of me)
   select tSaveSel
end textChanged
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Uppercase text

Post by dunbarx » Fri May 31, 2013 10:05 pm

I see you have wide programming experience.

In the interest of being purely pedantic, I just thought you should know four things:

1- How full LiveCode is of ready-made functionality. This point is made by Richard and Dixie's reference to the function "toUpper".

2- In the old days (two years ago?) one would have to do something horrific like this:

on keyDown tKey
if charToNum(tKey) >= 97 and charToNum(tKey) <= 122 then
put numToChar(charToNum(tKey) - 32) after me
else
pass keyDown
end if
end keyDown

You will see what is going on here right away, massaging the ASCII value of the character about to be written. I show it to you so you will get another look at how xTalk works, and the mechanics of making it do your bidding.

3- Even number two is head and shoulders more powerful, transparent and accessible than any other programming environment.

4- Welcome...

Craig Newman

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

Re: Uppercase text

Post by sandybassett » Sat Jun 01, 2013 8:33 pm

Thanks for the help, got it working fine in all but one place. In that field I want to limit length of input, limit to numbers and/or limit to '-' (like for phone numbers). With the if...then routine I can do any two of them but not three. Is there another way of handling multiple limits, kinda like the 'case...end case' statements in other languages? or any other suggestions on that.

Next I'm off to discover how to store data in SQLite and retrieve it to a scrolling list. I just need to synchronize my brain index with LC index of help notes.

nower
Posts: 47
Joined: Wed May 22, 2013 11:02 pm

Re: Uppercase text

Post by nower » Sun Jun 02, 2013 12:14 am

The switch ... end switch statement does that.
Look it up in the dictionary.

By the way, I also have previous coding experience, and I found the User Guide very helpful in getting a general understanding, as it describes all the basic concepts of LiveCode. You can get to it from the LiveCode Help menu.

Regarding the use of sqlite, this tutorial might be helpful (if you haven't already seen it):
http://lessons.runrev.com/s/lessons/m/4 ... e-database

Post Reply