comp.lang.ada
 help / color / mirror / Atom feed
* Converting Char to Enum
@ 2002-03-02 18:17 Lars Noschinski
  2002-03-03  1:15 ` sk
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Lars Noschinski @ 2002-03-02 18:17 UTC (permalink / raw)


Hello!

In my Ada95 program, I have a enumeration type defined as follows:

type symbols is ('0', '1', 'B', 'T', 'U');

The program takes a string from the command-line and needs to convert the 
chars to symbols. At the moment, I use a case-construct, but I wonder if 
there is a more elegant possibility.


CU Lars Noschinski



^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: Converting Char to Enum
@ 2002-03-06  6:23 Christoph Grein
  0 siblings, 0 replies; 17+ messages in thread
From: Christoph Grein @ 2002-03-06  6:23 UTC (permalink / raw)


> So if I want to output only the character without the quotes, I have
> to convert it to string?

No, you have to use the character operations of Text_IO (if your characters are 
of type Standard.Character. No conversion to Standard.String is necessary.

Note that you may write:
ote that you may write:

procedure My_Program is

  type My_Character is (something, 'A', 'a', 'B', 'b', anything);
  type My_String is array (Positive range <>) of My_Character;

  V: My_String := "AAbbbA" & something & "aBBB";

begin

  ...

end My_Program;

String literals like "AAbbbA" are available for all character types, a character 
type being a type with at least one character literal, a character literal being 
something like 'a'. Note that the apperance of something and anything above in 
the type definition does not prevent My_Character from being a character type, 
you only cannot put these literals into a string literal, you have to do it in 
the way above. These strings are however not compatible with Standard.String, so 
you cannot use Text_IO with them directly.



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2002-03-06  6:23 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-02 18:17 Converting Char to Enum Lars Noschinski
2002-03-03  1:15 ` sk
2002-03-03 16:43   ` Robert Dewar
2002-03-03 18:54     ` Lars Noschinski
2002-03-03 20:07       ` Larry Kilgallen
2002-03-03 20:21         ` Lars Noschinski
2002-03-03 22:46           ` Larry Kilgallen
2002-03-04  6:55           ` Jeffrey Carter
2002-03-03 20:13       ` tmoran
2002-03-03  6:30 ` tmoran
2002-03-04 11:01 ` sk
     [not found] ` <3C835426.DA864199@myob.com>
2002-03-04 12:48   ` David C. Hoos, Sr.
2002-03-04 16:36     ` Lars Noschinski
2002-03-04 23:17       ` David C. Hoos
2002-03-05 15:55         ` Lars Noschinski
2002-03-05 20:15           ` David C. Hoos
  -- strict thread matches above, loose matches on Subject: below --
2002-03-06  6:23 Christoph Grein

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