

Task

Obtain a valid   Y   or   N   response from the keyboard.

The keyboard should be flushed, so that any outstanding key-presses are removed, preventing any existing   Y   or   N   key-press from being evaluated.

The response should be obtained as soon as   Y   or   N   are pressed, and there should be no need to press an   enter   key.




print 1 "Enter Y for yes, or N for no. (not case sensitive)"
let loop=0
let keycode=0
while loop=0
let keycode=key()
if keycode=121
let response$="y"
let loop=1
elseif keycode=89
let response$="Y"
let loop=1
elseif keycode=110
let response$="n"
let loop=1
elseif keycode=78
let response$="N"
let loop=1
endif
wend
print 1 "You entered"+response$
end