How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the ERRE 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 ERRE 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 ERRE programming language
Source code in the erre programming language
!$KEY
................
! flush the keyboard buffer
! --------------------------------
! you can use POKE(198,0) in C-64
! ERRE version
! --------------------------------
REPEAT
GET(K$)
UNTIL K$=""
PRINT("Press Y or N to continue")
REPEAT
GET(K$)
UNTIL INSTR("YyNn",K$)<>0
!
! with C-64 you must write a line like
! UNTIL K$="Y" OR K$="N"
!
PRINT("The response was ";K$)
.................
You may also check:How to resolve the algorithm Hailstone sequence step by step in the 11l programming language
You may also check:How to resolve the algorithm Natural sorting step by step in the Racket programming language
You may also check:How to resolve the algorithm Pascal matrix generation step by step in the Maple programming language
You may also check:How to resolve the algorithm Fixed length records step by step in the Ruby programming language
You may also check:How to resolve the algorithm Sorting algorithms/Comb sort step by step in the IS-BASIC programming language