How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the Wee Basic 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 Wee Basic 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 Wee Basic programming language
Source code in the wee programming language
print 1 "Enter Y for yes, or N for no. (not case sensitive)"
let loop=0
let keycode=0
while loop=0
let keycode=key()
if keycode=121
let response$="y"
let loop=1
elseif keycode=89
let response$="Y"
let loop=1
elseif keycode=110
let response$="n"
let loop=1
elseif keycode=78
let response$="N"
let loop=1
endif
wend
print 1 "You entered"+response$
end
You may also check:How to resolve the algorithm Execute a system command step by step in the Gambas programming language
You may also check:How to resolve the algorithm Call a function step by step in the Cubescript programming language
You may also check:How to resolve the algorithm Find if a point is within a triangle step by step in the Phix programming language
You may also check:How to resolve the algorithm Perfect shuffle step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Numerical integration/Gauss-Legendre Quadrature step by step in the Go programming language