

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.




 
\ get a yes or no response from the keyboard
: yes-no
	con:key $20 bor
	dup 'y n:= if ;; then
	dup 'n n:= if ;; then
	drop yes-no ;
: no? 'n n:= if "No" else "Yes" then . ;
 
"Yes or no? " con:print  yes-no no?
cr bye
 