home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG013.ARC
/
GETYES.FUN
< prev
next >
Wrap
Text File
|
1979-12-31
|
2KB
|
58 lines
function GETYES : boolean;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{* Secure from the console a reply of yes (y) or no (n). *}
{* Return "true" if yes, "false" otherwise. *}
(* Note - while this function is employed specifically for the *)
(* program ANIMAL.PAS, it may, of course, be used with *)
(* advantage in other programs. *)
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
const
suffix = '? (Y/N) ';
prompt = ' Please reply yes (Y) or no (N): ';
yes = 'YES';
no = 'NO';
var
ans : char;
gotreply : boolean;
messy : boolean;
begin {getyes function}
write(suffix);
lowvideo;
gotreply := false;
getyes := false;
messy := false;
while gotreply = false do
begin {while}
read(kbd,ans);
case ans of
'Y', 'y' : begin {YES processor}
writeln(yes);
gotreply := true;
getyes := true;
normvideo
end; {YES processor}
'N', 'n' : begin {NO processor}
writeln(no);
gotreply := true;
getyes := false;
normvideo
end {NO processor}
end; {case}
if not gotreply
then begin {if not gotreply}
if messy
then delline
else begin
clreol;
writeln
end;
write(^G,prompt);
messy := true
end {if not gotreply}
end; {while}
end; {getyes function}