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,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c22608a39b6f5e7b X-Google-Attributes: gid103376,public From: Nick Wilson Subject: Re: Dynamic Array Sizing Date: 1999/06/20 Message-ID: <376C7D96.47FF7F2@hotmail.com>#1/1 X-Deja-AN: 491635085 Content-Transfer-Encoding: 7bit References: <376B1811.666F042@hotmail.com> X-Original-NNTP-Posting-Host: dialin383.picknowl.com.au X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@telstra.net X-Trace: nsw.nnrp.telstra.net 929857826 203.24.77.237 (Sun, 20 Jun 1999 15:50:26 EST) Organization: Customer of Telstra Big Pond Direct MIME-Version: 1.0 NNTP-Posting-Date: Sun, 20 Jun 1999 15:50:26 EST Newsgroups: comp.lang.ada Date: 1999-06-20T00:00:00+00:00 List-Id: > > > I can do two passes of the file, one to see the size, then declare the > > array in a block and do another pass to read the values into it. > > Do you need to read in all the data at once (into an array)? Can't you > just read the data from the file directly? > > There's not much difference between reading from a randomly-accessed > array object, versus reading from a randomly-accessed file object. The trouble comes about because it's a real time system and my understanding is that it would be a good idea to do as much of the initialisation before the system actually starts running. It would be possible to just open, read from the file however many times as necessary then close it until the next lookup. I'm just looking for a nicer way if I can. > > I don't know what you're trying to say here. Post a snippet of code, > enough for us to see the module structure. > -- spec package Lookup_Array is function Get_Array_Size return Positive; procedure Initialise_Array; function Lookup_Value(Index : in Positive) is end Lookup_Array; -- body package body Lookup_Array is type Array_Store is array (Positive range <>) of Boolean; Array_Size : Positive; function Get_Array_Size return Positive is Open file Finds size of array return Array_Size := the size of array data in the file end Get_Array_Size; declare The_Array : Array_Store (Array_Size); procedure Initialise_Array is reads values from file into the array end Initialise_Array; function Lookup_Value(Index : in Positive) is return The_Array(Index); end Looup_Value; end Lookup_Array; I know this code isn't right, but hopefully it points out the problem of where I can declare The_Array so that it is visible to outside calling functions such as Lookup_Value ?