comp.lang.ada
 help / color / mirror / Atom feed
From: Nick Wilson <snow_moose@hotmail.com>
Subject: Re: Dynamic Array Sizing
Date: 1999/06/20
Date: 1999-06-20T00:00:00+00:00	[thread overview]
Message-ID: <376C7D96.47FF7F2@hotmail.com> (raw)
In-Reply-To: m3vhckd737.fsf@mheaney.ni.net

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





  reply	other threads:[~1999-06-20  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-19  0:00 Dynamic Array Sizing Nick Wilson
1999-06-19  0:00 ` jerry
1999-06-19  0:00   ` jerry
1999-06-19  0:00   ` Matthew Heaney
1999-06-19  0:00     ` jerry
1999-06-20  0:00       ` Matthew Heaney
1999-06-21  0:00         ` jerry
1999-06-19  0:00 ` Tom Moran
1999-06-19  0:00 ` Matthew Heaney
1999-06-20  0:00   ` Nick Wilson [this message]
1999-06-20  0:00     ` Matthew Heaney
replies disabled

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