Page 1 of 1

Uppercase text

Posted: Fri May 31, 2013 7:57 pm
by sandybassett
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.

Re: Uppercase text

Posted: Fri May 31, 2013 8:07 pm
by Dixie
look at toUpper in the dictionary...

Re: Uppercase text

Posted: Fri May 31, 2013 8:09 pm
by FourthWorld
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

Re: Uppercase text

Posted: Fri May 31, 2013 10:05 pm
by dunbarx
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

Re: Uppercase text

Posted: Sat Jun 01, 2013 8:33 pm
by sandybassett
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.

Re: Uppercase text

Posted: Sun Jun 02, 2013 12:14 am
by nower
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