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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4d6ffb27cf9c5e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-17 09:45:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!psinet-eu-nl!psiuk-p4!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: How to read in very long strings. (was: HELP!!!!!!) Date: Wed, 17 Oct 2001 12:36:41 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9qkc2r$mec$1@nh.pace.co.uk> References: <9qk4lr$1tvj$1@newsreader1.mclink.it> <3bcdaa4e.11615702@news.geccs.gecm.com> NNTP-Posting-Host: dhcp-200-133.miami.pace.co.uk X-Trace: nh.pace.co.uk 1003336603 22988 136.170.200.133 (17 Oct 2001 16:36:43 GMT) X-Complaints-To: newsmaster@news.cam.pace.co.uk NNTP-Posting-Date: 17 Oct 2001 16:36:43 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:14828 Date: 2001-10-17T16:36:43+00:00 List-Id: It looks like a fair answer, but is likely to be rather slow in execution. How slow will depend on the implementation of Unbounded_String. It could end up doing a lot of dynamic allocation/deallocation as you append the characters one at a time. See my other post with a solution from AdaPower. (I'm not smart enough to dream up something this slick! But I *am* smart enough to steal^H^H^H^H^HReuse a good thing when I see it. :-) A really slick solution might be to produce some version combining both the recursion and the Unbounded_String - which I prefer to use over the plain vanilla String in most instances. MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com Web: http://www.mcondic.com/ "Chris M. Moore" wrote in message news:3bcdaa4e.11615702@news.geccs.gecm.com... > On Wed, 17 Oct 2001 16:34:03 +0200, "F" wrote: > > >I would like to make a program in wich a string is given in input and the > >dimension of it is unknown (till someone insert it...) > >HOW CAN I DO?????? (without using hundreds of lines) > > function Read_String_From_Keyboard return String is > Temp_Str : Ada.Strings.Unbounded.Unbounded_String := > Ada.Strings.Unbounded.Null_Unbounded_String; > Ch : Character; > begin > while not Ada.Text_IO.End_Of_Line loop > Ada.Text_IO.Get(Ch); > Temp_Str := Ada.Strings.Unbounded."&"(Temp_Str, Ch); > end loop; > return Ada.Strings.Unbounded.To_String(Temp_Str); > end Read_String_From_Keyboard; > > seems like the safest way. I haven't tried compiling this though so > who knows! > > -- > Chris M. Moore > Software engineer > speaking for myself