Page 1 of 1
How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 6:30 am
by cooper_tim13
I am making a two-player hangman game, and I have set a limit of 10 characters which is working fine:
Code: Select all
on keyDown
if the length of me = 10 then
beep
else
pass keyDown
end if
end keyDown
However, when I try to limit the character input to only lowercase characters, nothing seems to happen. I can still type any character I want.
Code: Select all
on keyDown inkey
if inkey is in "abcdefghijklmnopqrstuvwxyz" then
pass keyDown
else
beep
end if
end keyDown
How do I fix this? Thankyou.
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 7:48 am
by paul_gr
use something like this in the field script
-------------------------------------------------------
on keyDown theKey
if matchText(theKey,"[A-Z]") is false then
pass keyDown
end if
end keyDown
-------------------------------------------------------
Will block capital letters.
Paul
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 8:27 am
by cooper_tim13
Paul, sorry but this did not do anything. I am still allowed to type in any character.
Also, I want to block all keys, including the spacebar, from being pressed except for a-z, not just uppercase A-Z
Thankyou,
Cooper.
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 9:18 am
by jmburnod
Hi Cooper,
It works with casesensitive = true
Code: Select all
on keyDown inkey
set the casesensitive to true
if inkey is in "abcdefghijklmnopqrstuvwxyz" then
pass keyDown
else
beep
end if
end keyDown
Best regards
Jean-Marc
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 11:00 am
by Dixie
cooper_tim13...
The script posted by 'paul_gr' does work, and is a very nice solution to the problem you wanted solving. I would suggest that you look in the dictionary and read the entry for 'matchText'...
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 12:22 pm
by bn
actually Cooper wanted nothing but lowercase letters a-z, so paul_gr's example would be
Code: Select all
on keyDown theKey
if matchText(theKey,"[a-z]") is true then
pass keyDown
end if
end keyDown
Kind regards
Bernd
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 12:25 pm
by Dixie
Hi Bernd...
Paul_gr's script does give lowercase and not uppercase !...

His script is correct as it stands
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 12:27 pm
by bn
except that it also accepts number exclamation marks punctuation and so on.
Kind regards
Bernd
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 12:30 pm
by Dixie
Bernd...

You are splitting hairs.
'paul_gr's' script did just what the OP asked for when he replied... the OP did not ask for other things to be taken into consideration until later on in the post.
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 12:40 pm
by bn
You are splitting hairs.
reminds me of:
Q: "How are you?"
A: "Fine like a frog hair split by four"
Q: "I did not know frogs had hair?"
A: "See, that's how fine I am"
Kind regards
Bernd
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 6:53 pm
by dunbarx
Ho, ho, ho.
Code: Select all
on mouseUp
set the wholeMatches to "false"
if "a" = "A" then answer "Same"
set the wholeMatches to "true"
if "a" = "A" then answer "Same"
end mouseUp
A little knowledge is often a dangerous thing. Right out of the gate, know that if you limit a selection to, say, "a", LC will only look at the "character", not the ASCII value of that character. And the "wholeMtches" don't enter into it. So that methodology is the wrong one.
Craig Newman
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 6:53 pm
by dunbarx
Ho, ho, ho.
Code: Select all
on mouseUp
set the wholeMatches to "false"
if "a" = "A" then answer "Same"
set the wholeMatches to "true"
if "a" = "A" then answer "Same"
end mouseUp
A little knowledge is often a dangerous thing. Right out of the gate, know that if you limit a selection to, say, "a", LC will only look at the "character", not the ASCII value of that character. And the "wholeMtches" don't enter into it. So that methodology is the wrong one.
Craig Newman
Re: How to limit data entry to only lowercase letters?
Posted: Sat May 07, 2016 7:12 pm
by Dixie
WHAT ?!....
Re: How to limit data entry to only lowercase letters?
Posted: Sun May 08, 2016 7:40 am
by dunbarx
Dixie.
What "what"?
I wanted to make the point that one could compare the ASCII value of "a' with the ASCII value of "A", and get the fact that they are different. But not be able to compare "a" with "A" directly.
"MatchText" is a regex gadget, and though is likely the best solution, may be daunting for a new user.
Craig