

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.




 
nomainwin
open "Y/N" for graphics_nsb_nf as #1
#1 "trapclose Quit"
#1 "down;setfocus;when characterInput KeyCheck"
#1 "place 10 50;\Press Y or N"
Inkey$=""
wait
 
sub KeyCheck hndle$,k$
    k$=upper$(k$)
    #hndle$ "cls;place 10 50"
    select case k$
        case "Y"
        #hndle$ "\ Yes"
        case "N"
        #hndle$ "\No"
        case else
        #hndle$ "\Incorrect input. Press Y or N"
        end select
    end sub
 
sub Quit hndle$
    close #hndle$
    end
    end sub
 