From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: how to "put" a binary structure? (newbie question!)
Date: Wed, 1 Feb 2006 19:23:11 +0100
Date: 2006-02-01T19:23:05+01:00 [thread overview]
Message-ID: <1746vbn77p1ox$.1e40mzswxb002$.dlg@40tude.net> (raw)
In-Reply-To: drqpnb$43l$00$1@news.t-online.com
On Wed, 1 Feb 2006 18:04:43 +0100, Norbert Caspari wrote:
> I like to print the content of a binary bit structure with the put
> statement but it doesn't work. I'm a newbie to Ada programming and
> therefore please excuse if my question might be silly or stupid. Maybe I
> misunderstood something.
Structure is not an integer type. You have to choose between three options:
1. Record type (structure)
2. Array of bits, like array (Integer range 1..8) of Boolean or of Bit_T
3. Modular integer type (unsigned with bit-wise operations) mod 2**8,
Unsigned_8
> How can I correct the source code to print the values stored in the
> structure Xxx? Is it possible, to print the whole content of Xxx with just
> one put statement? Or alternatively how can I assign the content of Xxx to
> another variable of the type Unsigned_8 that I can use for output? Or is
> there maybe another way?
type Look_Up_Table is array (Unsigned_8) of Byte;
Translation_Table : constant Look_Up_Table :=
( (Off, Off, Off, Off, Off, Off, Off, Off),
(Off, Off, Off, Off, Off, Off, Off, On),
(Off, Off, Off, Off, Off, Off, On, Off),
(Off, Off, Off, Off, Off, Off, On, On),
...
(On, On, On, On, On, On, On, On)
);
function To_Byte (X : Unsigned_8) return Byte is
begin
return Translation_Table (X);
end To_Byte;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2006-02-01 18:23 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 [this message]
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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox