comp.lang.ada
 help / color / mirror / Atom feed
From: pa.dec.com!nntpd2.cxo.dec.com!shodha!wallace@decwrl.dec.com  (Richard Wal
Subject: help with Ada question
Date: 27 Oct 92 15:47:42 GMT	[thread overview]
Message-ID: <1992Oct27.154742.12210@nntpd2.cxo.dec.com> (raw)

wallace@shodha (Richard Wallace) writes:
: wallace@shodha (Richard Wallace) writes:
: : rwalker@barnacle.micro.umn.edu (robert walker) writes:
: : : 
: : : If neither an exit nor a goto statement were available for Ada, how
: : : might you simulate the action of an exit statement?
: : : 
: : 
: : The following is one of may ways to control loop itteration without the
: : exit and goto verbs.  Note that I've only shown monotonicly increasing
: : loop control.
: : 
: : You would have to introduce a guard action on the loop control statement an
d
: : use an if to control skipping statements thus:
: : 
: 
: It seems I wiped-out the other half of my emacs buffer!  Sorry!  I'll
: reconstruct the code fragment again.
: 
: code fragment:
: 

It seems my mailer is having problems...  I saved this file out and what got
posted is truncated.  Hmm...  I'll try ONE more time.

LOOP_COUNTER := 1;
LOOP_EXIT    := false;

MAIN_LOOP:

while ( not( LOOP_EXIT) and ( LOOP_COUNTER <= LOOP_MAXIMUM ) ) then

	{do statements}

	if {boolean clause} then
		LOOP_EXIT := true; -- setup for a psudeo exit
	end if;

	if not( LOOP_EXIT ) then -- psuedo exit statment in this guard.
		{do statements if guard is true, i.e. no exit statement}
	end if;

	LOOP_COUNTER := LOOP_COUNTER + 1;

end loop MAIN_LOOP;

This is one of many solutions.  I hope this helps.  Note that this is a
monotonically incrementing loop.  To do the reverse clause you'd have to
count down.  To change the increment you'd have to change the constant 1
in the LOOP_COUNTER assignment.

Aloha,
	Richard

--------------

Richard Wallace
Senior Software Engineer
Digital Equipment Corporation
301 Rockrimmon Blvd. South
CXO2-1/7A
Colorado Springs, CO 80919-2398
(719)548-2792
<wallace@cookie.enet.dec.com>

"The opinions expresses are my own, B.P. may not *quite* agree..."

             reply	other threads:[~1992-10-27 15:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-10-27 15:47 pa.dec.com!nntpd2.cxo.dec.com!shodha!wallace [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-11-04  3:11 help with Ada question portal!cup.portal.com!R_Tim_Coslet
1992-11-01  9:05 Paul Schwartz
1992-10-27 15:31 pa.dec.com!nntpd2.cxo.dec.com!shodha!wallace
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox