Code archives/Algorithms/Allowed letters

This code has been declared by its author to be Public Domain code.

Download source code

Allowed letters by Andres
(Posted 22 years ago)
How to allow only wanted letters to be entered. In past i did all this by long if sentence to allow only the valid letters in my games and stuff, but i found a neat technique instead of it.

In this example only upper cased letters are allowed
Print "Waiting for correct letter to end..."

AllowedLetters$ = "ABCDEFGHIJKLMNOPQRSTUVWXY"

While Not Instr(AllowedLetters$, key$)
    key$ = Chr$(GetKey())
Wend
End

Comments

None.

Code Archives Forum