From: "Martin Dowie" <martin.dowie@btopenworld.com>
Subject: Re: Getting valid Integer values !!
Date: Tue, 21 Oct 2003 20:15:50 +0000 (UTC)
Date: 2003-10-21T20:15:50+00:00 [thread overview]
Message-ID: <bn445m$2a3$1@sparta.btinternet.com> (raw)
In-Reply-To: Fxflb.1900$VQ3.239738@news20.bellglobal.com
"CheGueVerra" <chegueverra@hotmail.com> wrote in message
news:Fxflb.1900$VQ3.239738@news20.bellglobal.com...
> [code snippet]
> package Entiers is new Text_io.Integer_io (Num => Integer);
Assuming you haven't got a prior "use Ada", for new code you
should call it "Ada.Text_IO" - "Text_IO" is listed as an "Obsolescent"
feature.
> IntData : integer range 1000000..9999999;
This is an "anonymous type" - generally considered bad (esp. for
exported things, not so bad when used localling within a subprogram).
You should declare a 'subtype' for this range.
> ValidKey : Boolean := false;
Not needed - see later
> begin
> put_line("Test Valid Key");
>
> while not ValidKey loop
loop
> begin
> Put_line(" Enter Key :");
> Entiers.Get(IntData);
> ValidKey := True;
exit; -- this is the canonical method
> exception
> When Data_error | Constraint_error =>
> Put_line(" Error reading value, Integer expected of range ...");
> Skip_line;
> end;
> end loop;
>
> Put_Line("Valid data entered");
Must be valid to get out of the loop
> Keep in mind that I can't use an exit in a loop so I used the boolean
value,
> it seems to work but ada has surprised me before ....
Why can't you use an exit?
next prev parent reply other threads:[~2003-10-21 20:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-21 19:11 Getting valid Integer values !! CheGueVerra
2003-10-21 20:15 ` Martin Dowie [this message]
2003-10-21 20:27 ` CheGueVerra
2003-10-21 23:04 ` Martin Dowie
2003-10-21 23:35 ` CheGueVerra
2003-10-22 2:49 ` Steve
2003-10-22 0:46 ` Jeffrey Carter
2003-10-22 1:07 ` CheGueVerra
-- strict thread matches above, loose matches on Subject: below --
2003-10-21 20:34 Beard, Frank Randolph CIV
2003-10-21 21:34 ` CheGueVerra
2003-10-21 21:36 ` CheGueVerra
[not found] <mailman.161.1066792253.25614.comp.lang.ada@ada-france.org>
2003-10-22 3:46 ` Jeff C,
2003-10-22 19:27 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox