How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the FutureBasic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the FutureBasic programming language

Table of Contents

Problem Statement

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.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the FutureBasic programming language

Source code in the futurebasic programming language

void local fn DoDialog( ev as long )
  CFStringRef key
  
  select ( ev )
    case _windowKeyDown
      cls
      key = fn EventCharacters
      select ( lcase(key) )
        case @"y",@"n"
          printf @"You pressed the \"%@\" key",key
          DialogEventSetBool(YES)// we handled the event
      end select
  end select
end fn

subclass
window 1, @"Press \"Y\" or \"N\" keys", (0,0,550,400)

on dialog fn DoDialog

HandleEvents

  

You may also check:How to resolve the algorithm Doubly-linked list/Element definition step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Sum multiples of 3 and 5 step by step in the FBSL programming language
You may also check:How to resolve the algorithm Closures/Value capture step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Empty program step by step in the Hare programming language
You may also check:How to resolve the algorithm XML/Output step by step in the Lasso programming language