comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Converting Type Characters to type string
Date: Tue, 1 Apr 2008 10:03:47 -0700 (PDT)
Date: 2008-04-01T10:03:47-07:00	[thread overview]
Message-ID: <9f7800f8-7383-4335-ad86-d0a22cfc11a9@i29g2000prf.googlegroups.com> (raw)
In-Reply-To: 25b98c63-ef00-4f5f-aa63-169dbcedde8b@2g2000hsn.googlegroups.com

On Apr 1, 6:22 am, jedivaughn <jedivaugh...@gmail.com> wrote:
> What I'm doing is taking the first character the user enters and
> looking at it to determine whether or not it is a integer roman
> numeral or the letter Q (for quit). if it's a integer then I need to
> convert the single character to a roman numeral and I take the rest of
> the input as a string and convert it to an integer using
>
> int := integer'value(char);
>
> so basically I then need to know how to convert the single character I
> used to determine whether or not the input was a integer roman numeral
> or the letter Q to an integer. And then I can add it to the integer to
> find the roman numeral vlaue.

I think you're really on the wrong track.  Assuming you've taken my
advice and are using Get_Line to read an entire string first, you can
look at the first character of the string to see whether it's Q or a
digit.  Once you've done this, the input string will still be there in
its entirety, including the first character that you've checked for
'Q'.  So why do you need to convert that one digit to an integer?  You
can still convert the entire input string using Integer'Value.

Even if for some reason you have to use Get_Immediate to read the
first character, you can store that character in a string, use
Get_Line to read the rest of the string, use one of several methods
(concatenation and slices come to mind) to put the first character
together with the rest of the string, then use Integer'Value to
convert the string as a whole.

Unless I'm misunderstanding the task you're trying to accomplish, I
don't see any reason why you would have to deal with converting a
single character to an integer.

                            -- Adam



  reply	other threads:[~2008-04-01 17:03 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-30 20:04 Converting Type Characters to type string jedivaughn
2008-03-30 20:19 ` Pascal Obry
2008-03-30 21:08   ` jedivaughn
2008-03-30 21:28     ` jimmaureenrogers
2008-03-30 21:38     ` Ludovic Brenta
2008-03-30 21:48   ` Georg Bauhaus
2008-03-30 23:52     ` jedivaughn
2008-03-31  3:04       ` george.priv
2008-03-31  4:00         ` tmoran
2008-03-31  8:54           ` Ludovic Brenta
2008-03-31  9:59             ` Dmitry A. Kazakov
2008-03-31 10:59               ` Jean-Pierre Rosen
2008-03-31 13:50                 ` jedivaughn
2008-03-31 14:11                   ` Ludovic Brenta
2008-03-31 14:21                   ` Dmitry A. Kazakov
2008-03-31 14:44                     ` jedivaughn
2008-03-31 15:41                       ` Adam Beneschan
2008-03-31 20:26                         ` Maciej Sobczak
2008-03-31 22:06                           ` Georg Bauhaus
2008-03-31 22:33                           ` Adam Beneschan
2008-04-01  1:00                             ` jedivaughn
2008-04-01  5:34                               ` Simon Wright
2008-04-01 11:22                                 ` jedivaughn
2008-04-01 12:00                                   ` jimmaureenrogers
2008-04-01 13:22                                     ` jedivaughn
2008-04-01 17:03                                       ` Adam Beneschan [this message]
2008-04-01 21:11                                   ` Simon Wright
2008-04-01 22:22                                     ` jedivaughn
2008-04-03  5:54                                   ` tmoran
2008-04-03 14:38                                     ` Adam Beneschan
2008-04-01 16:58                               ` Adam Beneschan
2008-03-31 15:45                       ` 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