comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
Subject: Re: Newbie question on Ada TExt_IO
Date: Fri, 4 Oct 2002 13:00:41 -0500
Date: 2002-10-04T13:00:41-05:00	[thread overview]
Message-ID: <mailman.1033754463.12901.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: Gwkn9.622$Oa1.417@nwrddc02.gnilink.net

You might find some useful ideas for simpler ways to accomplish
this in my "toy" application found at ftp.ada95.com/pub/pet_store.zip

For example, the pet_store-price.adb file shows how to use the
'Value attribute to do all of that work for you -- i.e., "trimming"
the leading and trailing blanks, etc.

Another consideration is that in general to find the length of the
input string one should use something like Last - Input'First + 1;
----- Original Message -----
From: "Justin Birtwell" <jbirtwell@yahoo.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Friday, October 04, 2002 12:49 PM
Subject: Re: Newbie question on Ada TExt_IO


> Steve,
>
> <<, I would read the value
> into a string using something like Text_Io.Read_Line with the string
> ridiculously large (maybe 1..256). >>
> I couldn't find the package Text_IO.Read_Line did you mean Get_Line?
>
> What 's the difference between having a huge array like String(1..256) and
> using an Unbounded_String?  Is it because we need the type to be
> specifically String and not Unbounded_String?  Couldn't we convert from
one
> to the other?
>
> << If after reading the string the value of
> "last" is the size of the string, I know something is wrong and report an
> error (unlikely to happen, but handled).  Once I get a reasonably sized
> string, I trim leading and trailing spaces using Ada.Fixed.Trim.  >>
>
> How do you evaluate the length of the string using "Input'Last" isn't
always
> going to be 256, it was for me?
>
> <<Then I check for valid characters using something like
> Ada.Strings.Fixed.Index to
> make sure the numeric input contains only digits.  Then I use the
> Integer'Value to get the actual value of the numeric string.  Just to be
> safe the Integer'Value conversion is protected by an exception handler.>>
>
> The Index function has a pattern matching parameter, how do you express
"all
> digits" without having to specify them individually?
>
> Thanks for your help,
> Justin
>
>
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>




  reply	other threads:[~2002-10-04 18:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-03 18:20 Newbie question on Ada TExt_IO Justin
2002-10-03 18:50 ` Matthew Heaney
2002-10-03 19:05 ` Jeffrey Carter
2002-10-03 19:35 ` David C. Hoos
2002-10-03 19:35 ` tmoran
2002-10-03 19:43 ` Preben Randhol
2002-10-03 19:55   ` Matthew Heaney
2002-10-03 20:07     ` Preben Randhol
2002-10-04  2:42 ` SteveD
2002-10-04 17:49   ` Justin Birtwell
2002-10-04 18:00     ` David C. Hoos [this message]
2002-10-04 18:04       ` Preben Randhol
2002-10-04 18:00     ` Preben Randhol
2002-10-04 18:02       ` Preben Randhol
2002-10-04 18:34     ` tmoran
2002-10-04 17:34 ` Justin Birtwell
2002-10-04 17:58   ` Preben Randhol
2002-10-04 18:13   ` tmoran
2002-10-04 20:07   ` Jeffrey Carter
2002-10-07  8:26     ` Fraser Wilson
2002-10-07 19:44       ` Jeffrey Carter
2002-10-05  2:43   ` SteveD
2002-10-05  5:25     ` tmoran
  -- strict thread matches above, loose matches on Subject: below --
2002-10-07  6:01 Grein, Christoph
2002-10-07  8:27 Grein, Christoph
2002-10-07 11:48 ` Fraser Wilson
2002-10-07 12:46   ` 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