{ case statements The "case" statement gives you a compact way to make several different decisions, depending on the value of some variable. This program demonstrates a simple use of a case statement. Fool around with this program until you understand how it works. Then move on to "menu.p" where you will write your own case statement. } program caseTest(input,output); var something : char; { This procedure achieves lasting world peace. } procedure WorldPeace; begin writeln( 'This is a "stub" procedure,' ); writeln( 'which means that its real contents have' ); writeln( 'yet to be written. The program will' ); writeln( 'be complete once all stubs are replaced' ); writeln( 'by the completed procedures.' ) end; begin write( 'Please enter a character: ' ); readln( something ); writeln; case something of 'A': writeln( 'Yabba dabba doo.' ); 'B', 'C': writeln( 'Either a B or a C will get you here.' ); 'D': begin writeln( 'You can do more than one thing for a' ); writeln( 'single case either by calling a procedure' ); writeln( 'or by enclosing the action with a begin/end pair.' ); writeln( 'Usually, it''s best to call a procedure, since' ); writeln( 'that makes the code easier to read.' ); writeln; end; 'E': WorldPeace; default: begin writeln( 'Everything else goes here.' ); writeln( 'This is not standard Pascal, but' ); writeln( 'it is very handy. In standard Pascal,' ); writeln( 'if you entered a case that wasn''t listed' ); writeln( 'in the case statement, your program would' ); writeln( 'stop running.' ) end; end; writeln; writeln( 'Thanks for playing.' ) end.