From: "Keith Allan Shillington" <keith@sd.aonix.com>
Subject: Re: Exception problem
Date: 1997/02/19
Date: 1997-02-19T00:00:00+00:00 [thread overview]
Message-ID: <01bc1e81$850234a0$fc00af88@godiva> (raw)
In-Reply-To: 330A0D25.313@fs2.assist.uci.edu
Classic error. If you input a non-numeric character, it gets "stuck" in the
input buffer and never processed. To throw away unwanted characters in the
input buffer, the simplest thing to do is add a call to Text_IO.Skip_Line in
each of your handlers.
Larry Coon <larry@fs2.assist.uci.edu> wrote...
>
> 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.");
Skip_Line;
> when Data_Error =>
> Put_Line ("Entry must be a number. Try again.");
Skip_Line;
> end;
> end loop; ...
next prev parent reply other threads:[~1997-02-19 0:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-02-18 0:00 Exception problem Larry Coon
1997-02-18 0:00 ` Michael Feldman
1997-02-19 0:00 ` Larry Coon
1997-02-19 0:00 ` Keith Allan Shillington [this message]
1997-02-19 0:00 ` David C. Hoos, Sr.
1997-02-19 0:00 ` Larry Coon
1997-02-19 0:00 ` Robert Dewar
1997-02-19 0:00 ` Joerg Rodemann
1997-02-19 0:00 ` Mats Weber
1997-02-22 0:00 ` Arthur Evans Jr
1997-02-24 0:00 ` Larry Coon
1997-02-24 0:00 ` Larry Kilgallen
1997-02-24 0:00 ` Larry Coon
1997-02-25 0:00 ` Fergus Henderson
1997-02-25 0:00 ` Do-While Jones
1997-03-09 0:00 ` John Volan
1997-03-09 0:00 ` Robert Dewar
1997-03-12 0:00 ` Keith Thompson
1997-02-25 0:00 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox