From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,eee47022b0e39dbb,start X-Google-Attributes: gid103376,public From: Larry Coon Subject: Exception problem Date: 1997/02/18 Message-ID: <330A0D25.313@fs2.assist.uci.edu>#1/1 X-Deja-AN: 219679471 Content-Type: text/plain; charset=us-ascii Organization: University of California Mime-Version: 1.0 Newsgroups: comp.lang.ada X-Mailer: Mozilla 2.01 (Win95; I) Date: 1997-02-18T00:00:00+00:00 List-Id: Ada beginner here... The intent of the following code is to loop until valid input is provided: declare X: Positive; package Int_IO is new Integer_IO (Integer); use Int_IO; begin loop begin Put ("Enter a positive number: "); Get (X); exit; -- No exception, so input was valid. exception when Constraint_Error => Put_Line ("Entry must be positive. Try again."); when Data_Error => Put_Line ("Entry must be a number. Try again."); end; end loop; -- Procesing for X.... end; The idea is that if input is not valid an exception will be thrown, the appropriate message will be displayed, and the code will loop back to the prompt. If no exception is thrown the input is valid, and the exit statement take the program out of the loop. This code handles non-positive numeric input (eg: 0 or -3) correctly. But when I give it non-numeric input (eg: C), it displays the "Entry must be a number. Try again" message repeatedly and never stops for input again. Compiler is Thomson Academic ObjectAda V7.0.171 in Win 95. I'd appreciate any insight. Larry Coon University of California larry@fs2.assist.uci.edu