Anonymous user
Keyboard input/Obtain a Y or N response: Difference between revisions
Keyboard input/Obtain a Y or N response (view source)
Revision as of 12:44, 10 February 2012
, 12 years agoAdd Seed7 example
No edit summary |
(Add Seed7 example) |
||
Line 343:
end
</lang>
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
include "keybd.s7i";
const func boolean: yesOrNo (in string: prompt) is func
result
var boolean: yes is FALSE;
local
var char: answer is ' ';
begin
while keypressed(KEYBOARD) do
ignore(getc(KEYBOARD));
end while;
write(prompt);
repeat
answer := lower(getc(KEYBOARD));
until answer in {'y', 'n'};
yes := answer = 'y';
end func;
const proc: main is func
begin
writeln(yesOrNo("Press Y or N to continue "));
end func;</lang>
=={{header|Tcl}}==
|