Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Converting ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 26 of 27 Topic 5627 of 5827
Post > Topic >>

Re: Converting Type Characters to type string

by Adam Beneschan <adam@[EMAIL PROTECTED] > Apr 1, 2008 at 10:03 AM

On Apr 1, 6:22 am, jedivaughn <jedivaugh...@[EMAIL PROTECTED]
> 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
 




 27 Posts in Topic:
Re: Converting Type Characters to type string
Georg Bauhaus <rm.plus  2008-03-30 23:48:32 
Re: Converting Type Characters to type string
jedivaughn <jedivaughn  2008-03-30 16:52:58 
Re: Converting Type Characters to type string
george.priv@[EMAIL PROTEC  2008-03-30 20:04:38 
Re: Converting Type Characters to type string
tmoran@[EMAIL PROTECTED]   2008-03-30 23:00:17 
Re: Converting Type Characters to type string
Ludovic Brenta <ludovi  2008-03-31 01:54:24 
Re: Converting Type Characters to type string
"Dmitry A. Kazakov&q  2008-03-31 11:59:30 
Re: Converting Type Characters to type string
Jean-Pierre Rosen <ros  2008-03-31 12:59:28 
Re: Converting Type Characters to type string
jedivaughn <jedivaughn  2008-03-31 06:50:32 
Re: Converting Type Characters to type string
"Dmitry A. Kazakov&q  2008-03-31 16:21:36 
Re: Converting Type Characters to type string
Ludovic Brenta <ludovi  2008-03-31 07:11:07 
Re: Converting Type Characters to type string
jedivaughn <jedivaughn  2008-03-31 07:44:52 
Re: Converting Type Characters to type string
"Dmitry A. Kazakov&q  2008-03-31 17:45:21 
Re: Converting Type Characters to type string
Adam Beneschan <adam@[  2008-03-31 08:41:25 
Re: Converting Type Characters to type string
Maciej Sobczak <see.my  2008-03-31 13:26:36 
Re: Converting Type Characters to type string
Georg Bauhaus <rm.tsoh  2008-04-01 00:06:22 
Re: Converting Type Characters to type string
Adam Beneschan <adam@[  2008-03-31 15:33:45 
Re: Converting Type Characters to type string
jedivaughn <jedivaughn  2008-03-31 18:00:03 
Re: Converting Type Characters to type string
Simon Wright <simon.j.  2008-04-01 06:34:17 
Re: Converting Type Characters to type string
jedivaughn <jedivaughn  2008-04-01 04:22:55 
Re: Converting Type Characters to type string
Simon Wright <simon.j.  2008-04-01 22:11:26 
Re: Converting Type Characters to type string
tmoran@[EMAIL PROTECTED]   2008-04-03 00:54:01 
Re: Converting Type Characters to type string
Adam Beneschan <adam@[  2008-04-03 07:38:57 
Re: Converting Type Characters to type string
"jimmaureenrogers@[E  2008-04-01 05:00:49 
Re: Converting Type Characters to type string
jedivaughn <jedivaughn  2008-04-01 06:22:49 
Re: Converting Type Characters to type string
Adam Beneschan <adam@[  2008-04-01 09:58:20 
Re: Converting Type Characters to type string
Adam Beneschan <adam@[  2008-04-01 10:03:47 
Re: Converting Type Characters to type string
jedivaughn <jedivaughn  2008-04-01 15:22:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 0:10:37 CDT 2008.