From: "Stephane Richard" <stephane.richard@verizon.net>
Subject: Re: Question about Ada and constant Arrays
Date: Mon, 10 Nov 2003 17:10:11 GMT
Date: 2003-11-10T17:10:11+00:00 [thread overview]
Message-ID: <TDPrb.6713$bQ3.4800@nwrdny03.gnilink.net> (raw)
In-Reply-To: slrnbqvhev.97p.randhol+valid_for_reply_from_news@kiuk0156.chembio.ntnu.no
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]
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" <randhol+valid_for_reply_from_news@pvv.org> wrote in
message
news:slrnbqvhev.97p.randhol+valid_for_reply_from_news@kiuk0156.chembio.ntnu.no...
> On 2003-11-10, Stephane Richard <stephane.richard@verizon.net> 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."
next prev parent reply other threads:[~2003-11-10 17:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-10 16:49 Question about Ada and constant Arrays Stephane Richard
2003-11-10 17:07 ` Preben Randhol
2003-11-10 17:10 ` Stephane Richard [this message]
2003-11-10 17:13 ` Preben Randhol
2003-11-10 17:11 ` Preben Randhol
2003-11-11 5:41 ` Nick Roberts
2003-11-11 9:34 ` Lutz Donnerhacke
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox