Page 1 of 1

ON keyDown theKey not working as expected

Posted: Fri Sep 11, 2009 6:14 pm
by user#606
I had hoped to cause a program to launch when the correct access code was typed in to a field.

global ServerPath,DemoLiveSetting, filenm,VersionTxt,Tposition,CodeNo,Tlength,Tchar,TempText
ON keyDown theKey
IF theKey is a number THEN pass keyDown --works for typing a number only into a field
put 0 into Tposition
put 0 into CodeNo
put the length of field "Addressfield" into Tlength --Field "address" contains a name
repeat for Tlength
put Tposition + 1 into Tposition
put char Tposition of field "Addressfield" into Tchar
put CodeNo + charToNum (Tchar) into CodeNo
end repeat -- this breaks down the name into a sum of ascii characters that form the unlock code
if field "CodeField" contains CodeNo then -- tests to see if the number so far matches the unlock code
launch "\Pt-G\Pt-G Designer version\Windows\Pt-G Designer version.exe" -- this is the program to launce (it does, only if a non-number is typed after the true code)
end if
END keyDown

It works fine if the code number is terminated with a non-digit E.G. 123a
when the correct value is 123.
It will not work for 1234 for example.
Why is this?
Any ideas on how to make this work.

Posted: Fri Sep 11, 2009 6:29 pm
by bn
since you pass keydown in case of a number you effectively only reach the part of your code after the pass statement if typing a non-number, like a.
if you dont pass the keydown but instead put

Code: Select all

if theKey is a number then put theKey after me
your code should work
regards
Bernd

Posted: Fri Sep 11, 2009 6:35 pm
by user#606
By jingo! That works!

I will mention you in my list of Credits
Thanks so much.