* here are the two case examples bundled together * note that you have to take them apart to play with them and that neither compiles procedure testCase is begin -- examples from the Ada95 reference manual case sensor is when Elevation => Record_Elevation (Sensor_Value); when Azimuth => Record_Azimuth (Sensor_Value); when Distance => Record_Distance (Sensor_Value); when others => null; end case; case Today is when Mon => compute_Initial_Balance; when Fri => compute_Closing_Balance; when Tue..Thu => generate_report (today); when Sat..Sun => null; end case; case Bin_Number(count) is when 1 => update_bin(1); when 2 => update_bin(2); when 3 | 4 => empty_bin(1); empty_bin(2); when others => raise error; end case; --as soon as an alternative is activated and carried out, control leaves the case statement. -- a break is not needed and ONLY ONE alternative can be selected. -- can you have duplicate values end testCase; ************************** with ada.integer_text_io; with ada.text_io; procedure testCase2 is number : integer; begin -- examples from the Ada95 reference manual case number is when 1 => ada.integer_text_io.put (number); when 2 => ada.integer_text_io.put (number); when 3 | 4 => ada.integer_text_io.put (number); when 5 => ada.integer_text_io.put (number); when 3..7 => ada.integer_text_io.put (number); -- causes compilation error due to duplicate values when others => ada.text_io.put ("ha ha "); end case; --as soon as an alternative is activated and carried out, control leaves the case statement. -- a break is not needed and ONLY ONE alternative can be selected. -- can you have duplicate values NO NO NO end testCase2;