From: "Beard, Frank Randolph CIV" <frank.beard@navy.mil>
To: "CheGueVerra" <chegueverra@hotmail.com>, <comp.lang.ada@ada-france.org>
Subject: RE: Getting valid Integer values !!
Date: Tue, 21 Oct 2003 16:34:52 -0400
Date: 2003-10-21T16:34:52-04:00 [thread overview]
Message-ID: <mailman.153.1066768561.25614.comp.lang.ada@ada-france.org> (raw)
We have a similar loop that we used on our older
console interfaces. Using your example, it would be:
...
type IntData_Type is range 1000000..9999999;
IntData : IntData_Type := IntData_Type'first;
ValidKey : Boolean := false;
package Entiers is new Text_io.Integer_io (Num => IntData);
begin
put_line("Test Valid Key");
loop
begin
Put(" Enter Key : "); --+ Not Put_Line
Entiers.Get(IntData);
New_Line(2);
exit;
exception
When Data_error | Constraint_error =>
New_Line;
Put_line(" Error reading value, Integer expected of range ...");
Skip_line;
end;
end loop;
Put_Line("Valid data entered");
...
I don't follow why you can't use an exit.
Frank
-----Original Message-----
From: CheGueVerra [mailto:chegueverra@hotmail.com]
Sent: Tuesday, October 21, 2003 15:12
To: comp.lang.ada@ada-france.org
Subject: Getting valid Integer values !!
Hi guys it's me again,
Well after so much time playing with Ada I think I'm starting to get the
beat of it a special thanks to all those who have helped and will help down
the road...
Now, after testing a bit, this is the procedure I want to use to make sure
that the Integer values entered are valid and are in the range that I expect
them to be, it seems to be working fine, I'll test some more after the post,
but if you see some things that I Might have not thought of please tell me
so
[code snippet]
package Entiers is new Text_io.Integer_io (Num => Integer)
IntData : integer range 1000000..9999999;
ValidKey : Boolean := false;
begin
put_line("Test Valid Key");
while not ValidKey loop
begin
Put_line(" Enter Key :");
Entiers.Get(IntData);
ValidKey := True;
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");
...
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 ....
TIA
CheGueVerra
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada-france.org
http://www.ada-france.org/mailman/listinfo/comp.lang.ada
next reply other threads:[~2003-10-21 20:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-21 20:34 Beard, Frank Randolph CIV [this message]
2003-10-21 21:34 ` Getting valid Integer values !! 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
-- strict thread matches above, loose matches on Subject: below --
2003-10-21 19:11 CheGueVerra
2003-10-21 20:15 ` Martin Dowie
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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox