comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Beginner Question
Date: Wed, 20 Oct 2010 15:43:28 -0700
Date: 2010-10-20T15:43:28-07:00	[thread overview]
Message-ID: <i9nrj9$65b$1@tornado.tornevall.net> (raw)
In-Reply-To: <90ceb514-83aa-44c2-b253-218956d8426d@d17g2000yqm.googlegroups.com>

On 10/20/2010 02:41 PM, SpoonThief wrote:
> So, I have a question that may seem painfully obvious, but how does
> one go about parsing a Float from a string that has other data in it
> too? I'm getting a line from the keyboard that has a float and a
> custom type in it, and I need to separate the two values. I'm using a
> call to Get_Line to get the entire line the user entered as a string,
> and when I try to call Float'Value (In_String (1 .. Last)), I get a
> constraint error. Is there any way to parse a float and a custom
> subtype (Excellent, Good, Fair, Poor) from one string, or am I going
> about this the entirely wrong way? Any help would be much appreciated,
> and if clarification is needed because I wasn't clear, just ask. Thank
> you in advance!

You might want to look at Ada.Text_IO.Float_IO, specifically

procedure Get(From : in String; Item : out Num; Last : out Positive);

(ARM A.10.1; http://www.adaic.org/standards/05rm/html/RM-A-10-1.html).

-- 
Jeff Carter
"You empty-headed animal-food-trough wiper."
Monty Python & the Holy Grail
04



  reply	other threads:[~2010-10-20 22:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-20 21:41 Beginner Question SpoonThief
2010-10-20 22:43 ` Jeffrey Carter [this message]
2010-10-20 22:45 ` Adam Beneschan
2010-10-21  7:28 ` Dmitry A. Kazakov
replies disabled

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