IsAlpha also accepts DEL etc. Bug or a feature?

Report any Hollywood bugs here
Post Reply
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

IsAlpha also accepts DEL etc. Bug or a feature?

Post 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?
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

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

Post 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.
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

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

Post 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.
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

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

Post 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
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

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

Post by Bugala »

Good idea, will use that myself too.
Post Reply