Re: Converting Type Characters to type string
- From: Adam Beneschan <adam@xxxxxxxxxx>
- Date: Tue, 1 Apr 2008 10:03:47 -0700 (PDT)
On Apr 1, 6:22 am, jedivaughn <jedivaugh...@xxxxxxxxx> 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
.
- References:
- Re: Converting Type Characters to type string
- From: Adam Beneschan
- Re: Converting Type Characters to type string
- From: jedivaughn
- Re: Converting Type Characters to type string
- From: Simon Wright
- Re: Converting Type Characters to type string
- From: jedivaughn
- Re: Converting Type Characters to type string
- From: jimmaureenrogers@xxxxxxxxxxxxxxxx
- Re: Converting Type Characters to type string
- From: jedivaughn
- Re: Converting Type Characters to type string
- Prev by Date: Re: Converting Type Characters to type string
- Next by Date: Re: GnatBench (from GPL edition)
- Previous by thread: Re: Converting Type Characters to type string
- Next by thread: Re: Converting Type Characters to type string
- Index(es):
Relevant Pages
|