ON keyDown theKey not working as expected
Posted: Fri Sep 11, 2009 6:14 pm
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.
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.