From: Richard Riehle <richard@adaworks.com>
Subject: Re: how to create an array of N elements?
Date: Mon, 19 Aug 2002 18:28:47 -0700
Date: 2002-08-20T01:23:49+00:00 [thread overview]
Message-ID: <3D619B4F.9551C98D@adaworks.com> (raw)
In-Reply-To: c923f575.0208191223.6073ebf4@posting.google.com
drmed wrote:
> thank you.
>
> then an other question:
>
> list : unbounded_string;
> type page is array(Positive range <>) of list;
> text : page(1 .. 300);
>
> but how can I change the number of elements in runtime? for example I
> delete a element of the array text or add one so that the array text
> now has only 200 elements and really only 200 elements and not contain
> a null string.
Consider using a declare block. For example,
with ada.integer_text_io;
procedure Dynamic_Array is
Size : Positive := 300;
begin
ada.integer_text_io.get(size);
Variable_Size_Array_Block:
declare
S : String(1..Size);
begin
for I in S'Range
loop
null;
end loop;
end Variable_Size_Array_Block;
end Dynamic_Array;
Many Ada developers will recommend a better
approach such as nesting a subprogram in the
declarations of the enclosing unit and passing the
new size as a parameter. Either way, you can
accomodate variable size array declarations in
your program if you need them.
Richard Riehle
next prev parent reply other threads:[~2002-08-20 1:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <c923f575.0208170639.344c3c21@posting.google.com>
2002-08-17 16:16 ` how to create an array of N elements? Warren W. Gay VE3WWG
[not found] ` <c923f575.0208191223.6073ebf4@posting.google.com>
2002-08-20 1:28 ` Richard Riehle [this message]
2002-08-20 15:08 ` Stephen Leake
[not found] ` <3d63525a_4@news.bluewin.ch>
2002-08-26 18:11 ` 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