

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.




include c:\cxpl\codes;          \intrinsic 'code' declarations
loop    [OpenI(1);              \flush any pending keystroke
        case ChIn(1) of         \get keystroke
         ^Y,^y: Text(0, "yes");
         ^N,^n: Text(0, "no");
         $1B:   quit            \Esc key terminates program
        other ChOut(0, 7\bel\);
        CrLf(0);
        ]