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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,22666a247c07ba1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-10 21:41:52 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!82-43-33-75.cable.ubr01.croy.blueyonder.co.UK!not-for-mail From: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: Question about Ada and constant Arrays Date: Tue, 11 Nov 2003 05:41:41 +0000 Message-ID: References: NNTP-Posting-Host: 82-43-33-75.cable.ubr01.croy.blueyonder.co.uk (82.43.33.75) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1068529311 50647795 82.43.33.75 (16 [25716]) User-Agent: Mozilla/5.0 (Windows; U; Win95; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en In-Reply-To: Xref: archiver1.google.com comp.lang.ada:2320 Date: 2003-11-11T05:41:41+00:00 List-Id: Just for fun, a possible refinement might be something like this: ~~~ with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure Array_Init_2 is package Boolean_IO is new Enumeration_IO(Boolean); use Boolean_IO; function "+" (Source: in String) return Unbounded_String renames To_Unbounded_String; procedure Put (Item: in Unbounded_String) is begin Put( To_String(Item) ); end; type Test_Record is record Enabled : Boolean; Name : Unbounded_String; Value : Integer; end record; type Test_Array is array (Positive range <>) of Test_Record; My_Array : constant Test_Array := (1 => (True, +"Test1", 1), 2 => (False, +"Test2", 2), 3 => (False, +"Test3", 4), 4 => (False, +"Test4", 8), 5 => (True, +"Test5 (whoopee)", 16), 6 => (False, +"Test *** 6 ***", 17)); begin -- Printing the values to show that it is correct. for i in My_Array'Range loop Put(i); Put(" => "); Put(My_Array(i).Enabled); Put(", "); Put(My_Array(i).Name); Put(", "); Put(My_Array(i).Value); New_Line; end loop; end Array_Init_2; ~~~ I haven't tested this code. -- Nick Roberts