From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_00,PLING_QUERY, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5ffde75d5ac5a4c2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news3.google.com!news2.volia.net!news.germany.com!news.belwue.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: how to "put" a binary structure? (newbie question!) Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Wed, 1 Feb 2006 19:23:11 +0100 Message-ID: <1746vbn77p1ox$.1e40mzswxb002$.dlg@40tude.net> NNTP-Posting-Date: 01 Feb 2006 19:23:05 MET NNTP-Posting-Host: 295b88b3.newsread2.arcor-online.net X-Trace: DXC=bHYI6P99L:LL0\Y_Wg[Z[NQ5U85hF6f;DjW\KbG]kaMHCZ8X]Y4193NEZF;0MKW2lMWRXZ37ga[7JjTA67ckJ=XE^\Uo1i\<2eH X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:2736 Date: 2006-02-01T19:23:05+01:00 List-Id: 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