ASCII number manipulation
Posted: Tue May 31, 2016 11:57 am
Hi, this is my first post on the LiveCode forums!
So I have a teensy problem. I have a keyDown operator which detects any key with the parameters [a-zA-Z].
Perhaps if I show you my code it will make more sense.
If you can see what I'm trying to do now, what I want is to input a single char A-Z in upper or lowercase, then:
- convert it to lowercase, then
- convert the lowercase char to ASCII then
- minus value x from that, where x is the number that would reduce the result number to 1 if I input 'a'
So yeah, basically I want it to convert the keypress of a into 1 and z into 26, including every letter in between of course.
Ignore checkForCharacterMatch, thats an external function that has no effect on my question.
The error message I get when I try to run the above code points to the first put operator under the if statement.
Could someone who's awesome help me out on this?
So I have a teensy problem. I have a keyDown operator which detects any key with the parameters [a-zA-Z].
Perhaps if I show you my code it will make more sense.
Code: Select all
on keyDown theKey
if matchText(theKey,"[a-zA-Z]") then
put (numToChar(lower(theKey))-140) into temp1
put temp1 into keyPressed
checkForCharacterMatch theKey
end if
end keyDown
- convert it to lowercase, then
- convert the lowercase char to ASCII then
- minus value x from that, where x is the number that would reduce the result number to 1 if I input 'a'
So yeah, basically I want it to convert the keypress of a into 1 and z into 26, including every letter in between of course.
Ignore checkForCharacterMatch, thats an external function that has no effect on my question.
The error message I get when I try to run the above code points to the first put operator under the if statement.
Could someone who's awesome help me out on this?