Page 1 of 1

IsAlpha also accepts DEL etc. Bug or a feature?

Posted: Fri Apr 25, 2025 10:30 am
by Bugala
Example code:

Code: Select all

EscapeQuit(True)
InstallEventHandler({onkeydown = Function(event) If IsAlpha(event.key) = True Then DebugPrint(event.key) EndFunction})
Repeat
	WaitEvent()
Forever
Manual says "Checks if the character at index pos inside string s$ is an alphabetic letter and returns True if it is, otherwise False."

But when using this example code on Hollywood 10, Windows 11, by pressing DEL, RETURN, BACKSPACE, also give TRUE.

Based upon the explanation, I would expect it to return TRUE only on Alphabetic letters, not on DEL, RETURN...

Bug or a Feature?

Re: IsAlpha also accepts DEL etc. Bug or a feature?

Posted: Fri Apr 25, 2025 12:02 pm
by Flinx
Works as expected.
IsAlpha(s$[, pos, encoding]) tests one character of the string s$, and if the “pos” argument is omitted, it tests the first character.
The first character of the string “DEL” is a D, which is an alphabetic character, just like the B in “BACKSPACE”. Only with “RETURN” I can't follow you, because the return key event on my machine returns a line break and not a “RETURN” string, and your script then responds correctly with FALSE.

Re: IsAlpha also accepts DEL etc. Bug or a feature?

Posted: Mon Apr 28, 2025 2:18 pm
by Bugala
@flinx

Yes indeed, you are right. Somehow thought that "DEL" etc. are like single key markings, but of course they are simply strings. Especially from IsAlpha commands point of view.

Re: IsAlpha also accepts DEL etc. Bug or a feature?

Posted: Tue Apr 29, 2025 5:34 pm
by Flinx
If you want to use IsAlpha() then you could filter out all strings with more than one character, then it is usable I think.
My function for the virtual keyboard has such a line (after checking for DEL) to ignore all function keys and so on:

Code: Select all

If StrLen(key$)<>1 Then Return

Re: IsAlpha also accepts DEL etc. Bug or a feature?

Posted: Tue Apr 29, 2025 6:35 pm
by Bugala
Good idea, will use that myself too.