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,b62b9163b26144cf X-Google-Attributes: gid103376,public From: John English Subject: Re: Exit Loop_Statement Date: 2000/05/09 Message-ID: <3917C83E.D088C4DF@bton.ac.uk>#1/1 X-Deja-AN: 621028307 Content-Transfer-Encoding: 7bit References: <8f7oep$khc$1@enyo.uwa.edu.au> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: news@bton.ac.uk X-Trace: saturn.bton.ac.uk 957859983 16085 193.62.183.204 (9 May 2000 08:13:03 GMT) Organization: University of Brighton Mime-Version: 1.0 NNTP-Posting-Date: 9 May 2000 08:13:03 GMT Newsgroups: comp.lang.ada Date: 2000-05-09T08:13:03+00:00 List-Id: David Freshwater wrote: > procedure Buy is > begin > [...snip...] > Any_File : > Loop > > Put("Please enter the clients name : "); > Get_Line(Item => Any (I + 1).Clients, Last => P_L_C); > Put("Olympic Sponsor? (Enter True or False) : "); > Boolean_Io.Get(Sponsor); > exit Any_File when Any(I+1).Clients(1..3) = "Stop"; That should be Clients(1..4), right? You should convert to e.g. lower case if you want case insensitivity: if Ada.Characters.Handling.To_Lower(Clients(1..4)) = "stop" then ... > [...snip...] > end loop Any_File; > > exception > > when DATA_ERROR|NUMERIC_ERROR => You should really use Constraint_Error instead of Numeric_Error (although they both mean the same thing). Also, don't you want the exception to be handled inside the loop so the user can re-enter the data? At the moment, it'll print an error message, call Save_File, and then you're at the end of the program... Try something like this: loop begin ... exception ... end; end loop; Your exit statement will get you out of the loop; an exception will be handled by the exception handler inside the loop, so after you've handled the exception you'll go round the loop again. HTH, ----------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.it.bton.ac.uk/staff/je Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk -----------------------------------------------------------------