interface

uses crt;

implementation

{ --------------------------------------------------------------------
by Emil Mikulic

Input:
s - the string to display (the question)

Output:
boolean - true if answer is yes and false if answer is no

Intraction:
User has to type Y or N
-------------------------------------------------------------------- }
var c:char;
begin
{ Write the question }
write(s);
repeat
{ Get the uppercase answer }
{ Until it's Y or N }
until (c='Y') or (c='N');
{ Write out the choice and move down a line }
writeln(c);

{ Return true if the answer was Y }
end;

{ --------------------------------------------------------------------
by Emil Mikulic

Input:
s    - the string to display (the question)
resp - a string containing the possible responses

Output:
integer - the number of the selected choice
Ex. AskCH('Pick a vowel:','AEIOU'), A=1 E=2 I=3 O=4 U=5

Intraction:
User has to type one of the letters is RESP
Note: case doesn't matter
-------------------------------------------------------------------- }
var c:char;
i,j:integer;
ok:boolean;
begin
{ Write out the question }
write(s);
repeat
{ Make sure ok is false }
ok:=false;
{ See if the answer is allowed in RESP, if yes, set ok to true }
for I:=1 to length(resp) do if c=upcase(resp[i]) then ok:=true;
{ Until it's ok :) }
until ok;
{ Write out the answer and move down a line }
writeln(c);

{ Find which part of RESP allows the answer }
for i:=1 to length(resp) do if c=resp[i] then j:=i;
{ Return it }
end;

{ --------------------------------------------------------------------
by Emil Mikulic

Input:
s   - the string to display (the question)
min - the lowest digit
max - the highest digit

Output:
integer - the digit entered

Intraction:
User has to type a digit between min and max
Note: if you make min greater than 9, it will loop forever
-------------------------------------------------------------------- }
var c:string;
i,j:integer;
begin
{ It's hard to type with one hand while eating a sandwich. }
write(s);
repeat
{ Get a response }
{ Turn it into an integer }
val(c,i,j);
{ Keep going until it's a proper integer (j=0) and it's allowed by
min and max }
until (j=0) and (i>min) and (i<max);
{ Write out the answer }
writeln(c);
{ Return it }
end;

end.

by Emil Mikulic

--------------------------------------------------------------------
by Emil Mikulic

Input:
s - the string to display (the question)

Output:
boolean - true if answer is yes and false if answer is no

Intraction:
User has to type Y or N

Examples:
if AskYN('Do you like me?') then format_drive(C);

--------------------------------------------------------------------
by Emil Mikulic

Input:
s    - the string to display (the question)
resp - a string containing the possible responses

Output:
integer - the number of the selected choice

Intraction:
User has to type one of the letters is RESP

Note:
Case doesn't matter

Examples:

--------------------------------------------------------------------
by Emil Mikulic

Input:
s   - the string to display (the question)
min - the lowest digit
max - the highest digit

Output:
integer - the digit entered

Intraction:
User has to type a digit between min and max

Note:
If you make min greater than 9, it will loop forever

Example:
Writeln('(1) Attack');
Writeln('(2) Run');
...
Writeln('(5) Cast the magical forces of GHGDFKG:LFWEF');
choice:=AskNO('What do you want to do?',1,5);
...
--------------------------------------------------------------------