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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6edeb2a39724bbc0 X-Google-Attributes: gid103376,public From: matthew_heaney@acm.org (Matthew Heaney) Subject: Re: Variable-length arrays (from a C programmer) Date: 1998/04/28 Message-ID: #1/1 X-Deja-AN: 348649670 Content-Transfer-Encoding: 8bit References: <353F9B75.3019A7A4@AlliedSignal.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Organization: Network Intensive Newsgroups: comp.lang.ada Date: 1998-04-28T00:00:00+00:00 List-Id: In article <353F9B75.3019A7A4@AlliedSignal.com>, "Paul T. McAlister" wrote: (start of quote) In "C" (see example), I can define an array of messages for each page, then define an array of pages for the whole thing. I don't have to worry about string length or number of items defined in the arrays, the compiler handles all of that for me. I have not been able to figure out how to do the equivalent thing in Ada. I don't know how to define strings without setting the length to the maximum length string I will have, which wastes a lot of space. I think I know how to define the variable length arrays for the messages for each screen, but I don't know how to define an array type of these arrays of string for each page (since they are different types because they are different lengths). I am using Ada83. (end of quote) You stated clearly that you are using Ada 83. However, I wanted to let you know that in Ada 95 there's a predefined string type that does exactly what you want. It's called Ada.Strings.Unbounded.Unbounded_String. In Ada 83, you'll have to roll your own dynamic string abstraction, something like package Unbounded_Strings is type Unbounded_String is limited private; procedure Append (S : String; To : in out Unbounded_String); procedure Clear (Source : Unbounded_String); ...