comp.lang.ada
 help / color / mirror / Atom feed
* Get (integer) help
@ 1997-05-21  0:00 sbredemeyer
  1997-05-22  0:00 ` Nick Roberts
  1997-05-22  0:00 ` Stephen Leake
  0 siblings, 2 replies; 3+ messages in thread
From: sbredemeyer @ 1997-05-21  0:00 UTC (permalink / raw)



I am relatively new to Ada 95 and am having trouble
with a GetInt library
unit that I have created. It is a simple procedure
with in parms of
Min_Allow, Max_Allow and Prompt_Text that out's
The_Integer.
I have created user defined exceptions handlers for
integer values
outside the range of Min_Allow .. Max_Allow
(The_Integer is
unconstrained, no subtype declaration), and used
Data_Error and
Constraint_Error as well.
The problem I am having is that my exception handler
handles inputs such
as Strings, > Integer'Last and integers out of range
Min_Allow ..
Max_Allow but spits the dummy if I input a real.
I know what is happening (i.e. given 1.234, GetInt
gets 1 as valid
integer input with the marker pointing to "." which
is then read in with
the next execution of the procedure) but not how to
get around it. I have
been trying to find documentation on look_ahead
which I think might solve
my problem, but with no success.
Can anybody help?

Please let me know if I have submitted this to an
inappropriate
NewsGroup. This is my first visit to DejaNews.

Thankyou

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Get (integer) help
  1997-05-21  0:00 Get (integer) help sbredemeyer
  1997-05-22  0:00 ` Nick Roberts
@ 1997-05-22  0:00 ` Stephen Leake
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Leake @ 1997-05-22  0:00 UTC (permalink / raw)



sbredemeyer@westpac.com.au wrote:
> 
> I am relatively new to Ada 95 and am having trouble with a GetInt library unit that I have created. It is a simple procedure with in parms of Min_Allow, Max_Allow and Prompt_Text that out's The_Integer.
> I have created user defined exceptions handlers for integer values
> outside the range of Min_Allow .. Max_Allow (The_Integer is
> unconstrained, no subtype declaration), and used Data_Error and
> Constraint_Error as well. The problem I am having is that my exception handler handles inputs such as Strings, Integer'Last and integers out of range Min_Allow .. Max_Allow but spits the dummy if I input a real.
> I know what is happening (i.e. given 1.234, GetInt gets 1 as valid
> integer input with the marker pointing to "." which is then read in with the next execution of the procedure) but not how to
> get around it. I have been trying to find documentation on look_ahead
> which I think might solve my problem, but with no success.
> Can anybody help?

I'm not clear what behavior you want. If your program calls GetInt, and
the user types "1.234", do you want GetInt to say "1.234 is not an
integer" ? If so, you need to read a whole line, using Get_Line, and not
just an integer, using Text_IO.Integer_IO.Get.

I wrote a similar package (in Ada 83). You can download it from my web
page:

http://www710.gsfc.nasa.gov/~sal714/homepage.html

follow the link to "Ada packages for Friendly Text_Io and Robot_Math",
and download text_io.tar.gz
> 
> Please let me know if I have submitted this to an
> inappropriate
> NewsGroup. This is my first visit to DejaNews.

You've come to the right place!
> 
> Thankyou
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet

-- 
- Stephe




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Get (integer) help
  1997-05-21  0:00 Get (integer) help sbredemeyer
@ 1997-05-22  0:00 ` Nick Roberts
  1997-05-22  0:00 ` Stephen Leake
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Roberts @ 1997-05-22  0:00 UTC (permalink / raw)





sbredemeyer@westpac.com.au wrote in article
<864270399.21858@dejanews.com>... {

I am relatively new to Ada 95 and am having trouble with a GetInt library
unit that I have created. It is a simple procedure with in parms of
Min_Allow, Max_Allow and Prompt_Text that out's The_Integer.  I have
created user defined exceptions handlers for integer values outside the
range of Min_Allow .. Max_Allow (The_Integer is unconstrained, no subtype
declaration), and used Data_Error and Constraint_Error as well.  The
problem I am having is that my exception handler handles inputs such as
Strings, > Integer'Last and integers out of range Min_Allow .. Max_Allow
but spits the dummy if I input a real.  I know what is happening (i.e.
given 1.234, GetInt gets 1 as valid integer input with the marker pointing
to "." which is then read in with the next execution of the procedure) but
not how to get around it.   I have been trying to find documentation on
look_ahead which I think might solve my problem, but with no success.  Can
anybody help?

Please let me know if I have submitted this to an inappropriate NewsGroup.
This is my first visit to DejaNews.

}

1. Please use a different way to post messages - your formatting came out
yukky!

2. Tell us your first name please; we are (usually :-) on first name terms
here.

3. Please give us a little bit more information about your problem. Why,
specifically, are you programming your own integer input (rather than using
the predefined library)? Just what behaviour do you require of it? Could
you post the (relevant) code, please?

Nick.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-05-22  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-05-21  0:00 Get (integer) help sbredemeyer
1997-05-22  0:00 ` Nick Roberts
1997-05-22  0:00 ` Stephen Leake

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