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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no 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:29:40 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.mathworks.com!wn13feed!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc04.POSTED!not-for-mail From: "Jeff C," Newsgroups: comp.lang.ada References: <3F8CB712.2070808@comcast.net> Subject: Re: array of strings in a function X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: NNTP-Posting-Host: 66.31.4.164 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc04 1066188579 66.31.4.164 (Wed, 15 Oct 2003 03:29:39 GMT) NNTP-Posting-Date: Wed, 15 Oct 2003 03:29:39 GMT Organization: Comcast Online Date: Wed, 15 Oct 2003 03:29:39 GMT Xref: archiver1.google.com comp.lang.ada:873 Date: 2003-10-15T03:29:39+00:00 List-Id: "Robert I. Eachus" wrote in message news:3F8CB712.2070808@comcast.net... > Antonio Mart�nez wrote: > > > I'm trying to pass to a function an argument. The argument is an > > array range <> of Strings (unbounded array). > > > number of string literals is unknown by the function. And the > > length of every string is unknown as well. > > > How do I work with unbound strings? > > You can create an array of Unbounded_String (found in > Ada.Strings.Unbounded). Or you can use the package below. Note that in > either case, you are going to have to create an array object, put the > strings in it, and then pass that to the array. With the package below > your example above: > Hmm.. Robert, I am not sure why you would have to create the array and then put the strings in it then pass the array (ok, I agree that is what is really going to happen...but you can hide it) with Ada.Strings.Unbounded; with Text_IO; procedure AnotherWay is function "-"(Item : in String) return Ada.Strings.Unbounded.Unbounded_String renames Ada.Strings.Unbounded.To_Unbounded_String; function "-"(Item : in Ada.Strings.Unbounded.Unbounded_String) return String renames Ada.Strings.Unbounded.To_String; type Unbounded_String_Array is array (Integer range <>) of Ada.Strings.Unbounded.Unbounded_String; procedure Something (Data : in Unbounded_String_Array) is begin for I in Data'range loop Text_IO.Put_Line(-Data(I)); end loop; end Something; begin Something((-"Hello", -", I'm", -" the function")); end AnotherWay; Now, having said and done this....I agree with Robert that this is not a normal Ada idiom so the original poster should really think about whether or not you want to do this. While the code I provided above will actually work, it is really a bad idea so if you can look at your problem space in a different manner, I would really recommend against doing this. Also one more note, the original post talked about writing a function to do something but the example (in the original post) was actually a procedure.