From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Enumeration I/O
Date: 1998/02/09
Date: 1998-02-09T00:00:00+00:00 [thread overview]
Message-ID: <mheaney-ya023680000902981932110001@news.ni.net> (raw)
In-Reply-To: 34DF9BBF.9FEA859B@er.uqam.ca
In article <34DF9BBF.9FEA859B@er.uqam.ca>, Melanie Shatilla
<hj791520@er.uqam.ca> wrote:
>I've declared an enumeration type with character literals, and a
>variable of this type, for example :
> TYPE Symbols is ('%', '$', 'a');
Don't name a type with a plural, unless it refers to a composite object.
An instance of the Symbol(s) type contains only a single value, so that's
how you should name the type:
type Symbol is ('%', '$', 'a');
> Symb : Symbols := '$';
>
> package Symbols_IO is new Text_IO.Enumeration_IO(Symbols);
>
>When I give the instruction :
> Symbols_IO.Put(Symb);
>
>...I get the right symbol but with the quotes (and I don't want them).
That is the defined behavior: character literals print out using the quotes.
>Obviously, I've thought of writing something like :
>
> If Symb = '$' then
> Text_IO.Put ('$');
> end if;
>
>..but there must be a more convenient way, I hope! Any suggestions
>anyone ?
You could implement a table:
type Symbol_Character_Array is
array (Symbol) of Character;
function To_Character : constant Symbol_Character_Array :=
('%' => '%',
'$' => '$',
'a' => 'a');
begin
Text_IO.Put (To_Charcter (Symb));
Another thing you can do is Put the Symbol object to a string, then just
print the middle character of the 3-byte string.
declare
Symbol_As_String : String (1 .. 3);
Symbol_As_Character : Character renames Symbol_As_String (2);
begin
Put (To => Symbol_As_String, Item => Symb);
Put (Symbol_As_Character);
end;
next prev parent reply other threads:[~1998-02-09 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-02-10 0:00 Enumeration I/O Melanie Shatilla
1998-02-09 0:00 ` Matthew Heaney [this message]
1998-02-10 0:00 ` John J. Cupak Jr.
1998-02-10 0:00 ` Nick Roberts
1998-02-11 0:00 ` Ray Blaak
-- strict thread matches above, loose matches on Subject: below --
1990-05-08 15:45 Rick Conn
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox