comp.lang.ada
 help / color / mirror / Atom feed
From: smize@news.imagin.net (Samuel Mize)
Subject: Re: Help: Dynamic-size arrays using record discriminant.
Date: 1998/10/16
Date: 1998-10-16T00:00:00+00:00	[thread overview]
Message-ID: <707p11$i1l$1@prime.imagin.net> (raw)
In-Reply-To: 361E3D0C.41AAC13B@classnet.co.il

In article <361E3D0C.41AAC13B@classnet.co.il>,
Alon Matas  <amatas@classnet.co.il> wrote:
>-- I have this problem:

I believe this will work:

    procedure PROBLEM is

        type ARRAY_TYPE  is array (INTEGER range <>) of NATURAL;
        type RECORD_TYPE (SIZE: INTEGER:= 5) is
                record
                        VECTOR: ARRAY_TYPE (1..SIZE);
                end record;
        REC: RECORD_TYPE;
             -- SIZE will be 5 by default
             -- enough space will be allocated by many compilers
             --  to hold largest possible value, i.e. with
             --  SIZE=integer'last
    begin
        -- * * *
         -- REC gets initial values somehow
        -- * * *


        -- add New_Value to the end of Rec
        Rec :=
            (SIZE => SIZE + 1,
             VECTOR => (VECTOR'RANGE
                         => VECTOR (VECTOR'FIRST..VECTOR'LAST),
                        VECTOR'LAST + 1 => New_Value));

Best,
Sam Mize

-- 
Samuel Mize -- smize@imagin.net (home email) -- Team Ada
Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam




      parent reply	other threads:[~1998-10-16  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-09  0:00 Help: Dynamic-size arrays using record discriminant Alon Matas
1998-10-11  0:00 ` Niklas Holsti
1998-10-13  0:00 ` Robert I. Eachus
1998-10-16  0:00 ` Samuel Mize [this message]
replies disabled

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