From: "Jeffrey R. Carter" <spam@spam.com>
Subject: Re: how to "put" a binary structure? (newbie question!)
Date: Thu, 02 Feb 2006 02:10:21 GMT
Date: 2006-02-02T02:10:21+00:00 [thread overview]
Message-ID: <hSdEf.324$UF1.4@newsread3.news.pas.earthlink.net> (raw)
In-Reply-To: <drqpnb$43l$00$1@news.t-online.com>
Norbert Caspari wrote:
> package Byte_Io is new Text_Io.Integer_Io(Byte => Unsigned_8);
> --^^^^^^^^^
> -- This does not work, why???
>
> The compiler says
>
> missing actual for instantiation of "Num"
> instantiation abandoned
As the compiler tells you, Ada.Text_IO.Integer_IO has a generic formal parameter
named "Num". You have not supplied an actual parameter for it.
In addition, you have supplied an actual for "Byte", but it has no such formal
parameter.
But things are just starting. Integer_IO is for signed integer types:
type T is range Lo .. High;
Unsigned_8 is a modular type:
type Unsigned_8 is mod 2 ** 8;
Ada.Text_IO.Modular_IO is for modular types.
> Byte_IO.Put(Xxx.Bit0,
> Width=>1,
> Base=>2);
But even with an instantiation of Modular_IO, this won't work, because Xxx.Bit0
is not a modular type, it's an enumeration type. Maybe you want an instantiation
of Ada.Text_IO.Enumeration_IO?
All scalar types have the attribute function 'Image that returns a String
representation of the value:
Bit_T'Image (Xxx.Bit0);
'Value works the other way.
For your type, Bit_T'Image (Off) = "OFF"; Bit_T'Image (On) = "ON".
It seems you want to output '0' or '1'. In that case, why use an enumeration
type? You could use an appropriate modular type:
type Bit_Value is mod 2;
I suggest you spend some time reading Annex A:
http://www.adaic.org/standards/95lrm/html/RM-A.html
especially A.10, "Text Input-Output":
http://www.adaic.org/standards/95lrm/html/RM-A-10.html
--
Jeff Carter
"My name is Jim, but most people call me ... Jim."
Blazing Saddles
39
prev parent reply other threads:[~2006-02-02 2:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-01 17:04 how to "put" a binary structure? (newbie question!) Norbert Caspari
2006-02-01 18:23 ` Dmitry A. Kazakov
2006-02-01 18:34 ` Georg Bauhaus
2006-02-01 18:59 ` Martin Krischik
2006-02-02 11:06 ` Stephen Leake
2006-02-02 2:10 ` Jeffrey R. Carter [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox