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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,22666a247c07ba1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-10 09:10:12 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!snoopy.risq.qc.ca!chi1.webusenet.com!news.webusenet.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny03.gnilink.net.POSTED!53ab2750!not-for-mail From: "Stephane Richard" Newsgroups: comp.lang.ada References: Subject: Re: Question about Ada and constant Arrays X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: Date: Mon, 10 Nov 2003 17:10:11 GMT NNTP-Posting-Host: 141.149.78.146 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny03.gnilink.net 1068484211 141.149.78.146 (Mon, 10 Nov 2003 12:10:11 EST) NNTP-Posting-Date: Mon, 10 Nov 2003 12:10:11 EST Xref: archiver1.google.com comp.lang.ada:2304 Date: 2003-11-10T17:10:11+00:00 List-Id: excellent, I sincerely doubted it couldn't, I just never actually saw such an example :-) Thanks Preben :-) -- "To err is human. To really screw up, you need C++!" St�phane Richard "Ada World" Webmaster http://www.adaworld.com "Preben Randhol" wrote in message news:slrnbqvhev.97p.randhol+valid_for_reply_from_news@kiuk0156.chembio.ntnu.no... > On 2003-11-10, Stephane Richard wrote: > > I'd like to make an constant array of a given record type and initialize it > > upon it's creation. > > [Delete unknown language (VHDL?)] > > Yes it can be done: > > ---8<-------8<------8<------- > > with Ada.Text_IO; use Ada.Text_IO; > > procedure arrayinit > is > > type Test_Record is > record > Enabled : Boolean; > Name : String(1 .. 5); > Value : Integer; > end record; > > type Test_Array is array (1 .. 5) 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", 16)); > begin > > -- Printing the values to show that it is correct. > > for i in My_Array'Range loop > Put_Line (Integer'Image (i) & " => " & > Boolean'Image (My_Array (i).Enabled) & "," & > My_Array (i).Name & "," & > Integer'Image (My_Array (i).Value)); > end loop; > > end arrayinit; > ---8<-------8<------8<------- > > > -- > "Saving keystrokes is the job of the text editor, not the programming > language."