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 X-Google-Thread: 103376,9fa5063fbdc75ae4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-14 20:08:24 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread4.news.pas.earthlink.net.POSTED!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: array of strings in a function References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Date: Wed, 15 Oct 2003 03:08:23 GMT NNTP-Posting-Host: 63.184.105.190 X-Complaints-To: abuse@earthlink.net X-Trace: newsread4.news.pas.earthlink.net 1066187303 63.184.105.190 (Tue, 14 Oct 2003 20:08:23 PDT) NNTP-Posting-Date: Tue, 14 Oct 2003 20:08:23 PDT Xref: archiver1.google.com comp.lang.ada:871 Date: 2003-10-15T03:08:23+00:00 List-Id: Antonio Mart�nez wrote: > I'm trying to pass to a function an argument. The argument is an > array range <> of Strings (unbounded array). > > For example: > > my_fun("Hello", ", I'm", " the function"); This looks like a procedure, not a function. > number of string literals is unknown by the function. And the > length of every string is unknown as well. > > It works if I choose a fixed length of the string, and every string > is exactly the length I have forced. > > So, if I fixed 4, it works for me: > my_fun("only", "four", "lette", "rs ", "are ", "allo", "ed "); You can't have a subprogram with an unknown number of parameters, which is what you've been trying to write. > How do I work with unbound strings? > > I want something like this: > > type Miarray is array (Positive range <>) of string; > > but it doen't compile !!! Of course not. String is an indefinite type, and the components of an array type must be definite. You say you want unbounded strings, so use unbounded strings: use Ada.Strings.Unbounded; type Mine is array (Positive range <>) of Unbounded_String; Then you can write procedure Proc (Arg : in Mine); and call it Proc (Arg => (To_Unbounded_String ("Hello") , To_Unbounded_String (", I am"), To_Unbounded_String (" Ada!") ); -- Jeff Carter "Death awaits you all, with nasty, big, pointy teeth!" Monty Python & the Holy Grail 20