

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.




 yn: Proc Options(main):
 Dcl sysin stream input;
 Dcl sysprint stream output;
 Dcl c Char(1);
 Put Skip List('Please enter Y or N');
 Get Edit(c)(a(1));
 Select(c);
   When('Y','y','J','j')
     Put Skip List('YES');
   When('N','n')
     Put Skip List('NO');
   Otherwise
     Put Skip List('Undecided?');
   End;
 End;