Page 1 of 1
Numbers Only, Letters Only & Symbols Only Fields
Posted: Wed Dec 19, 2007 5:32 pm
by deeverd
Hello Everyone,
Here's a contribution rather than a question:
Recently, I needed to find the script that would create a “Numbers-Onlyâ€
Posted: Thu Dec 20, 2007 2:47 am
by BvG
I like your minimalistic approach, but feel the need to show some of it's weaknesses:
Most symbols are in fact not smaller then "a", for example "€" (Euro). In addition, there are some possibilites that are in fact smaller then "a", but not symbols at all (mostly control characters, like tab or return). And of course this will only work with non-unicode stuff, because no matter wether number, char, symbol or control character, if it's not in ASCII, it's bigger then "a".
Finally there are rev speciality, for example case insensitiveness ("A" = "a"), and the reordering of symbols (if it where like ascii (or a derivate), "[" should be bigger then "A").
Character encoding is a very strange and uncharted jungle, and everyone who dares to enter, will sooner or later catch a strange tropical disease

Posted: Thu Dec 20, 2007 5:47 pm
by deeverd
Hello BvG,
I always enjoy your wisdom and wit, and learn much from your responses, since they usually challenge me to keep pushing the envelope. I see the flaws you mentioned, and must admit that this script was written from a North American point of view, completely forgetting the wide world of European and other symbols. The simple script works pretty good for here in the States (not perfect but good for most forms), but considering the world is much larger than my corner of the world, I'd certainly be very happy about seeing or assisting anyone in creating a more international version.
Cheers, deeverd
P.S. You certainly have a beautiful cat on your website. I live in the country and do what I can to protect some of the of cats that get dumped off there by the people from the city. I've even spent $1,000 on a wrought iron fence around my front porch to give them a place to safely hide from the coyotes, plus I have automatic feeders, automatic waterers, a dog house for them to keep warm in, big pet pillows, heat lamps on the wall, and so forth for the cat family that has taken residence there this year during the cold winter days.
Posted: Thu Dec 20, 2007 7:03 pm
by whelkybaby
Not sure if this will work in Rev, but from memory I used to do something like this in HyperCard:
Code: Select all
on keyDown theKey
if theKey is in "abcdefghi..." then pass keyDown
end keyDown
In between the quotes, I'd enter whatever characters were allowed be it letters only, numbers or whatever. I wonder if that still works?
Interesting Glitch
Posted: Thu Dec 20, 2007 7:51 pm
by deeverd
Hello Forum,
In my happy but nescient minimalist fashion, and until I discover a more elegant way, I am including another simple set of script for forcing “Caps Onlyâ€
Posted: Thu Dec 20, 2007 7:58 pm
by deeverd
Hi Whelkybaby,
I just checked your script:
Code: Select all
on keyDown theKey
if theKey is in "abcdefghi..." then pass keyDown
end keyDown
It definitely works in Revolution. The only drawback is that one must type everything they want into it, but that might be worth the effort to force only certain allowable keystrokes. It's a good idea.
All the best, deeverd
Posted: Sat Dec 22, 2007 2:32 am
by whelkybaby
Oh cool. Glad that works!
Steve
Lost in the ASCII Jungle
Posted: Mon Dec 24, 2007 3:57 pm
by deeverd
Hello Forum,
In my continuing explorations of the ASCII jungles, I have only just recently returned with script that should create a letters-only field that allows for not just merely the standard upper and lower-case English alphabet (found in my original code on this thread), but should now also include the alphabet on most European keyboards (hopefully.)
Note: It should be noted that I use Windows XP and therefore I have no idea what the ASCII numbers are for international letters on Mac OSx.
International Letters-Only Field with ASCII (Win XP Version)
Code: Select all
on keyDown theInternationalLettersKey
if theInternationalLettersKey >= numToChar(65) and theInternationalLettersKey <= numToChar(90) or theInternationalLettersKey >= numToChar(192) and theInternationalLettersKey <= numToChar(255) or theInternationalLettersKey >= numToChar(97) and theInternationalLettersKey <= numToChar(122) then pass keyDown
end keyDown
Since I do not own a keyboard with international letter keys on it, my code from above is untested, yet (with a bit of luck) the theory should be sound. In other words, I think it works.
Below is another version of a numbers-only field, only this time it uses ASCII numbers (also, sorry again that it's just a Win XP version.) I know that I need to buy a Mac someday, too.
ASCII Numbers-Only Field (Win XP Platform)
Code: Select all
on keyDown theASCIINumbersKey
if theASCIINumbersKey >= numToChar(48) and theASCIINumbersKey <= numToChar(57) then pass keyDown
end keyDown
A good thing about the code above is that it would be quite easy to also add other ASCII symbols to it such as numToChar(42) to (47) in order to include such mathematical signs as "*+-,./" and also numToChar(60) to (62) in order to include the signs "<=>" so that calculations could take place.
Anyway, I'd say that's enough jungle exploring for now. If anyone has any improvements to these fields, your enlightening comments are always welcome.
All the best and happy holidays, deeverd