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,1f8b4cce7e72b123 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-26 09:40:58 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!wn1feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc06-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3BD9922A.4192B330@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Arrays and Access types... References: <20011025214647.2788a60b.egm2@jps.net> <3BD8F70E.3667B286@worldnet.att.net> <20011025234515.5dfa2af1.egm2@jps.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 26 Oct 2001 16:40:58 GMT NNTP-Posting-Host: 12.86.35.216 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc06-news.ops.worldnet.att.net 1004114458 12.86.35.216 (Fri, 26 Oct 2001 16:40:58 GMT) NNTP-Posting-Date: Fri, 26 Oct 2001 16:40:58 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:15262 Date: 2001-10-26T16:40:58+00:00 List-Id: "Eric G. Miller" wrote: > > On Fri, 26 Oct 2001 05:39:09 GMT, James Rogers wrote: > > > --- Slicable array package > > generic > > Max_Size : Positive; > > type Element is private; > > package Slicing_Array is > > > > subtype Array_Index is Positive range 1..Max_Size; > > type Element_Array is array(Array_Index range <>) of Element; > > type Slicable_Array is private; > Try this example driver program to see how to instantiate a generic package. with Slicing_Array; with Ada.Text_Io; procedure Slicing_Test is Length : Positive := 10; package Slicing_Chars is new Slicing_Array (Max_Size => Length, Element => Character); procedure Print_Chars(Item : Slicable_Array) is Temp : Slicing_Chars.Element_Array(First(Item)..Last(Item)); begin Temp := Slicing_Chars.To_Array(Item); for index in Temp'Range loop Ada.Text_IO.Put(Temp(index)); end loop; Ada.Text_IO.New_Line; end Print_Chars; My_String : Slicing_Chars.Slicable_Array; Simple_String : Slicing_Chars.Element_Array(1..Length); begin for index in 1..10 loop Simple_String(index) := character'Val(Character'Pos('a') + index); end loop; My_String := Slicing_Chars.Create(Simple_String); Print_Chars(My_String); for num in reverse 1..10 loop Slicing_Chars.Slice(Item => My_String, First => 1, Last => Num); Print_Chars(My_String); end loop; end Slicing_Test; Jim Rogers Colorado Springs, Colorado USA