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,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f6a85e71d2c330ab X-Google-Attributes: gid103376,public From: "chad" Subject: Re: checking a loop execution Date: 2000/04/20 Message-ID: <38fece05.0@silver.truman.edu>#1/1 X-Deja-AN: 613623335 References: <8dl76u$etf$1@nnrp1.deja.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Trace: news.more.net 956245484 150.243.160.9 (Thu, 20 Apr 2000 10:44:44 CDT) X-MSMail-Priority: Normal NNTP-Posting-Date: Thu, 20 Apr 2000 10:44:44 CDT Newsgroups: comp.lang.ada Date: 2000-04-20T00:00:00+00:00 List-Id: The following code does what you want: declare Index : Integer := 1; Interupted : Boolean := False; begin loop Interupted := ; exit when Interupted or else (Index = 10); Index := Index + 1; end loop; if Interupted then Put_Line("Loop interupted at :" & Integer'Image(Index)); else Put_Line("Loop was not interupted."); end if; end; Although the above code seems a little verboes, I feel that it makes the logic clearer. wrote in message news:8dl76u$etf$1@nnrp1.deja.com... > Is there a way to check if a loop has been exited before completion or > if all iterations have been performed? > In fortran the loop index is increased one last time, at the end of > the loop, but in Ada that trick cannot be exploited; the index is not > even defined outside the loop. > I could add a control variable (ivar, in my example) to take care of the > iteration number when exiting, but that would decrease the peformance > of my algorithm > > Example > > procedure loop_test is > > ivar : integer; > > begin > for i in 1 .. 10 loop > if then > ivar := i; > exit ; > end if ; > end loop; > put(ivar,2); > end loop_test; > > > > thank you for your suggestions > > Pol > > > Sent via Deja.com http://www.deja.com/ > Before you buy.