{========================================================== menu.p Started by Jeff Ondich on 1/13/97 Last modified 1/13/97 This program demonstrates a simple menu-driven program structure. ==========================================================} program menu(input,output); var selection : char; done : boolean; {========================================================== BuyShoes orders a pair of shoes from an on-line shopping service. ==========================================================} procedure BuyShoes; begin writeln( '*****BuyShoes stub*****' ) end; {========================================================== TakeSnooze puts the computer's monitor into energy-saving "sleep" mode for ten minutes. ==========================================================} procedure TakeSnooze; begin writeln( '*****TakeSnooze stub*****' ) end; {========================================================== SingBlues entertains the user with a classic blues lyric. ==========================================================} procedure SingBlues; begin writeln( '*****SingBlues stub*****' ) end; {========================================================== Kangaroos does...honestly, I'm not really sure. ==========================================================} procedure Kangaroos; begin writeln( '*****Kangaroos stub*****' ) end; {========================================================== CountByTwos displays all the even integers from 2 to 100. ==========================================================} procedure CountByTwos; begin writeln( '*****CountByTwos stub*****' ) end; {========================================================== DrawMenu displays the menu, and prompts the user for a selection. The caller is responsible for reading and processing the user's selection. ==========================================================} procedure DrawMenu; begin writeln; writeln( 'A. Buy some shoes' ); writeln( 'B. Take a snooze' ); writeln( 'C. Sing the blues' ); writeln( 'D. Kangaroos' ); writeln( 'E. Count by twos' ); writeln( 'Q. Quit' ); writeln; write( 'Please type your selection: ' ) end; {========================================================== Main program ==========================================================} begin done := false; while not done do begin DrawMenu; readln( selection ); writeln; if (selection = 'a') or (selection = 'A') then BuyShoes else if (selection = 'b') or (selection = 'B') then TakeSnooze else if (selection = 'c') or (selection = 'C') then SingBlues else if (selection = 'd') or (selection = 'D') then Kangaroos else if (selection = 'e') or (selection = 'E') then CountByTwos else if (selection = 'q') or (selection = 'Q') then done := true else begin writeln; writeln( 'You selected an unavailable option.' ); writeln( 'Please try again.' ); writeln end end end.