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=-1.8 required=5.0 tests=BAYES_00,PLING_QUERY 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!news2.google.com!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: how to "put" a binary structure? (newbie question!) References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 02 Feb 2006 02:10:21 GMT NNTP-Posting-Host: 67.3.229.32 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.pas.earthlink.net 1138846221 67.3.229.32 (Wed, 01 Feb 2006 18:10:21 PST) NNTP-Posting-Date: Wed, 01 Feb 2006 18:10:21 PST Xref: g2news1.google.com comp.lang.ada:2742 Date: 2006-02-02T02:10:21+00:00 List-Id: 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