comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org>
Subject: Re: How to read in very long strings. (was: HELP!!!!!!)
Date: Wed, 17 Oct 2001 12:36:41 -0400
Date: 2001-10-17T16:36:43+00:00	[thread overview]
Message-ID: <9qkc2r$mec$1@nh.pace.co.uk> (raw)
In-Reply-To: 3bcdaa4e.11615702@news.geccs.gecm.com

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" <chris.m.moore@amsjv.com> wrote in message
news:3bcdaa4e.11615702@news.geccs.gecm.com...
> On Wed, 17 Oct 2001 16:34:03 +0200, "F" <phosphorus@libero.it> 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





  reply	other threads:[~2001-10-17 16:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-17 14:34 HELP!!!!!! F
2001-10-17 16:10 ` HELP!!!!!! Chris M. Moore
2001-10-17 16:36   ` Marin David Condic [this message]
2001-10-17 18:17   ` HELP!!!!!! Jeffrey Carter
2001-10-18  7:10   ` HELP!!!!!! F
2001-10-18  8:11     ` HELP!!!!!! Martin Dowie
2001-10-18 16:57       ` HELP!!!!!! Jeffrey Carter
2001-10-17 16:28 ` How to read in very long strings. (was: HELP!!!!!!) Marin David Condic
2001-10-17 22:18   ` Jeffrey Carter
2001-10-18 13:39     ` Marin David Condic
2001-10-17 17:31 ` HELP!!!!!! tmoran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox