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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a0833bbed8752e1f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: fmdf@tiscali.it (fabio de francesco) Newsgroups: comp.lang.ada Subject: Re: variable lenght strings Date: 22 Oct 2004 05:30:00 -0700 Organization: http://groups.google.com Message-ID: References: <417842cd$0$74191$39cecf19@news.twtelecom.net> NNTP-Posting-Host: 82.49.51.99 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1098448201 7211 127.0.0.1 (22 Oct 2004 12:30:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 22 Oct 2004 12:30:01 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:5631 Date: 2004-10-22T05:30:00-07:00 List-Id: "Matthew Heaney" wrote in message news:<417842cd$0$74191$39cecf19@news.twtelecom.net>... Hi, I thank you all for your kind support, that is what you always give. This is one more reason to be added to the enjoyment of learning Ada. [CUT] > The termination condition is as follows: you know that you've consumed the > entire line when Last < Line'Last. Good! I didn't know. [CUT] > If you want, you can use recursion to read the line, and return the string > as a function result: > > declare > function Get_Line (N : Positive := 80) return String is > Line : String (1 .. N + 1); > Last : Natural; > begin > Get_Line (Line, Last); > > if Last < Line'Last then > return Line (1 .. Last); > else > return Line & Get_Line (2 * N); > end if; > end Get_Line; > > Line : constant String := Get_Line; > begin > > This avoids the loop, and having to store intermediate results in a buffer. I like the method you explained. I suppose that I have to change the function name in order not to collide with the standard Get_Line. So I renamed it My_Get_Line, but when compiling I get: 22. return Line & My_Get_Line (2 * N); | >>> ambiguous operand for concatenation >>> possible interpretation at line 13 >>> possible interpretation at line 13 Line 13 is the line that starts My_Get_Line definition. Why is the operand ambiguous? Fabio De Francesco