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-Thread: 103376,ed290afd6f09a679 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Initialize with aggregate? Date: 21 Nov 2005 17:21:59 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1132602018.206322.285630@g44g2000cwa.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls4.std.com 1132611719 8343 192.74.137.71 (21 Nov 2005 22:21:59 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 21 Nov 2005 22:21:59 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:6521 Date: 2005-11-21T17:21:59-05:00 List-Id: ejijott@gmail.com writes: > Hi there! > > Regarding the code below, what syntax do I use to initialize tempstore > with an aggregate? > [code] > . > . > . > type node; > type storage is access node; > type node is > record > next: storage; -- Pekare till n�sta nod. > item: string(1..50); -- En textstr�ng > len: integer :=-1; -- L�ngden p� str�ngen. > count: integer := 0; -- Antalet f�rekomster av str�ngen > end record; > . > . > . > tempstore:=new Node; > tempstore.item(1 .. Val'length):=Val; > tempstore.len:=Val'length; > tempstore.count:=1; > if S /= null then > tempstore.next:=S; > end if; > S:=tempstore; > [/code] How about something like this: type node; type storage is access node; type node(len: natural) is record next: storage; -- Pekare till n�sta nod. item: string(1..len); -- En textstr�ng count: integer := 0; -- Antalet f�rekomster av str�ngen end record; tempstore:=new Node'( len => val'length, next => S, item => val, count => 1); S:=tempstore; Hardwiring Item'Length to 50 isn't a good idea, and it makes the programming harder, because you have to carefully avoid the junk at the end. - Bob