home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog4 / except4.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  1.9 KB  |  77 lines

  1.                                        -- Chapter 17 - Program 4
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Except4 is
  6.  
  7.    procedure Try_It is
  8.       VALUE : constant := 8;
  9.       subtype LIMIT_RANGE is INTEGER range 14..33;
  10.       Funny : LIMIT_RANGE := VALUE;
  11.    begin
  12.       Put_Line("We are in the Try_It procedure");
  13.    exception
  14.       when Constraint_Error =>
  15.               Put_Line("Constraint error occurred");
  16.               Put_Line("Detected in procedure Try_It");
  17.    end Try_It;
  18.  
  19.    procedure Try_To_Fix_It is
  20.    begin
  21.       Put_Line("We are in the Try_To_Fix_It procedure.");
  22.       Try_It;
  23.    exception
  24.       when Constraint_Error =>
  25.               Put_Line("Constraint error occurred");
  26.               Put_Line("Detected in procedure Try_To_Fix_It");
  27.    end Try_To_Fix_It;
  28.  
  29.  
  30. begin
  31.    Put_Line("Begin program here.");
  32.    for Count in 1..4 loop
  33.       Put_Line("Ready to call Try_To_Fix_It.");
  34.       Try_To_Fix_It;
  35.       New_Line;
  36.    end loop;
  37.    Put_Line("End of program.");
  38.  
  39.    exception
  40.       when Constraint_Error =>
  41.               Put     ("Range error detected at the");
  42.               Put_Line(" main program level.");
  43.               Put_Line("Program terminated.");
  44. end Except4;
  45.  
  46.  
  47.  
  48.  
  49. -- Result of execution
  50.  
  51. -- Begin procedure here.
  52. -- Ready to call Try_To_Fix_It.
  53. -- We are in the Try_To_Fix_It procedure.
  54. -- Constraint error occurred
  55. -- Detected in procedure Try_To-Fix_It
  56. --
  57.  
  58. -- Ready to call Try_To_Fix_It.
  59. -- We are in the Try_To_Fix_It procedure.
  60. -- Constraint error occurred
  61. -- Detected in procedure Try_To-Fix_It
  62. --
  63.  
  64. -- Ready to call Try_To_Fix_It.
  65. -- We are in the Try_To_Fix_It procedure.
  66. -- Constraint error occurred
  67. -- Detected in procedure Try_To-Fix_It
  68. --
  69.  
  70. -- Ready to call Try_To_Fix_It.
  71. -- We are in the Try_To_Fix_It procedure.
  72. -- Constraint error occurred
  73. -- Detected in procedure Try_To-Fix_It
  74. --
  75. -- End of program.
  76.  
  77.