From: John English <je@bton.ac.uk>
Subject: Re: Exit Loop_Statement
Date: 2000/05/09
Date: 2000-05-09T08:13:03+00:00 [thread overview]
Message-ID: <3917C83E.D088C4DF@bton.ac.uk> (raw)
In-Reply-To: 8f7oep$khc$1@enyo.uwa.edu.au
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
-----------------------------------------------------------------
next prev parent reply other threads:[~2000-05-09 0:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-05-09 0:00 Exit Loop_Statement David Freshwater
2000-05-09 0:00 ` Gautier
2000-05-09 0:00 ` Robert Dewar
2000-05-09 0:00 ` John English [this message]
2000-05-09 0:00 ` Robert Dewar
2000-05-09 0:00 ` David Freshwater
2000-05-09 0:00 ` DuckE
2000-05-09 0:00 ` John English
2000-05-09 0:00 ` John English
2000-05-09 0:00 ` Robert Dewar
2000-05-09 0:00 ` Ken Garlington
2000-05-10 0:00 ` Jeff Creem
2000-05-10 0:00 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox