comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Initialize with aggregate?
Date: Mon, 21 Nov 2005 21:49:31 +0000
Date: 2005-11-21T21:49:31+00:00	[thread overview]
Message-ID: <m23blpzn6c.fsf@grendel.local> (raw)
In-Reply-To: 1132602018.206322.285630@g44g2000cwa.googlegroups.com

ejijott@gmail.com writes:

> 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]

S := new Node'(Next => S,
               Item => <<a function padding Val to 50 characters>>,
               Len => Val'Length,
               Count => 1);

If S is null then it can do no harm to assign it to the new node's
Next field.

You might consider replacing Item and Len by a bounded string of
length up to 50.



  parent reply	other threads:[~2005-11-21 21:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-21 19:40 Initialize with aggregate? ejijott
2005-11-21 21:38 ` Gautier Write-only
2005-11-21 21:49 ` Simon Wright [this message]
2005-11-22 17:10   ` Adam Beneschan
2005-11-22 20:00     ` Simon Wright
2005-11-21 22:21 ` Robert A Duff
2005-11-22 16:57   ` Adam Beneschan
2005-11-22 20:07     ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox