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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ef01efac83f51e2e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-18 13:35:46 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: looping through variable length array Date: 18 Mar 2002 16:18:25 -0500 Organization: NASA Goddard Space Flight Center Message-ID: References: <3c96047c$1@pull.gecm.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1016486625 7579 128.183.220.71 (18 Mar 2002 21:23:45 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 18 Mar 2002 21:23:45 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com comp.lang.ada:21426 Date: 2002-03-18T21:23:45+00:00 List-Id: "Stephen Frackelton" writes: > i'm attempting to loop through a set of arrays, but theses arrays are of > different lengths to cater for various message sizes. > but i want to write the loop only once to cater for this. > how is the best way to model this ? Attributes! procedure Loop_Thru_Array (Item : in Some_Array_Type) is begin for I in Item'range loop ... end loop; end Loop_Thru_Array; > can i somehow use an unconstrained array ? Yes. To make different sized array objects all of the same type, you use an unconstrained array type. type Some_Array_Type is array (Some_Index_Type range <> ) of Whatever_Type; > if i have my data available in a fixed size array, how can i get > this variable into a format i can loop through, regardless of the > size of the array. Use a slice. Fixed_Data : Some_Array_Type (1 .. 100); Fixed_Data_Last : Some_Index_Type := 50; -- Suppose only 1 .. Fixed_Data_Last has real data Loop_Thru_Array (Fixed_Data (1 .. Fixed_Data_Last)); Hope this helps. -- -- Stephe