From: James Rogers <jimmaureenrogers@worldnet.att.net>
Subject: Re: Arrays and Access types...
Date: Fri, 26 Oct 2001 16:40:58 GMT
Date: 2001-10-26T16:40:58+00:00 [thread overview]
Message-ID: <3BD9922A.4192B330@worldnet.att.net> (raw)
In-Reply-To: 20011025234515.5dfa2af1.egm2@jps.net
"Eric G. Miller" wrote:
>
> On Fri, 26 Oct 2001 05:39:09 GMT, James Rogers <jimmaureenrogers@worldnet.att.net> 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
next prev parent reply other threads:[~2001-10-26 16:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-26 4:46 Arrays and Access types Eric G. Miller
2001-10-26 5:39 ` James Rogers
2001-10-26 6:45 ` Eric G. Miller
2001-10-26 16:40 ` James Rogers [this message]
2001-10-26 6:14 ` tmoran
2001-10-26 14:26 ` Ted Dennison
2001-10-26 19:31 ` chris.danx
2001-10-26 23:32 ` Jeffrey Carter
2001-10-27 1:08 ` Eric G. Miller
2001-10-27 2:09 ` DuckE
2001-10-27 4:23 ` Steven Deller
2001-10-27 18:30 ` Eric G. Miller
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox