home *** CD-ROM | disk | FTP | other *** search
- { EXAMPLE DOOR: Number Guess }
- { By Scott Baker }
- { }
- { This is a simple number guessing game. }
-
- program numdoor;
-
- uses doordriv;
-
- procedure DoTheTitle;
- begin;
- sclrscr;
- swriteln('Hello, '+user_first_name+
- ' '+user_last_name+
- '. Welcome to NumDoor!');
- swriteln('');
- end;
-
- procedure playgame;
- var
- thenum: word;
- playerguess: word;
- guessnum: byte;
- done: boolean;
- tempstr: string;
- begin;
- swriteln('I''m thinking of a number.'+
- ' Can you guess what it is?');
- swriteln('');
- guessnum:=0;
- randomize;
- thenum:=random(100)+1;
- done:=false;
- while not done do begin;
- inc(guessnum);
- swrite('Guess #');
- str(guessnum,tempstr);
- swrite(tempstr);
- swrite(': ');
- sread_num_word(playerguess);
- if playerguess>thenum then swriteln('Lower!') else
- if playerguess<thenum then swriteln('Higher!') else
- if playerguess=thenum then begin;
- swriteln('Correct!');
- done:=true;
- end;
- if guessnum=10 then done:=true;
- end; {while}
- if thenum<>playerguess then begin;
- swriteln('You Lost!');
- str(thenum,tempstr);
- swriteln('The number was '+tempstr+'.');
- end;
- end;
-
- procedure waitforkey;
- var
- ch: char;
- begin;
- swriteln('');
- swriteln('Press any key to continue.');
- sread_char(ch);
- end;
-
- begin;
- initdoordriver('DOORDRIV.CTL');
- dothetitle;
- playgame;
- waitforkey;
- end.
-
-