comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org>
Subject: Re: Storing A string
Date: Thu, 14 Feb 2002 13:07:19 -0500
Date: 2002-02-14T18:07:21+00:00	[thread overview]
Message-ID: <a4gucp$les$1@nh.pace.co.uk> (raw)
In-Reply-To: mailman.1013706303.15083.comp.lang.ada@ada.eu.org

There must be 50 ways to do what you're describing. The important thing to
remember is that Get_Line works like assignment - it replaces the content of
the string with the new content when you read.

Take note of the fact that Get_Line has a parameter called "Last" that
indicates the last character read for the line. Also note that you can
reference a slice of a string as in: Some_String (Start_Pos..End_Pos), so
you could utilize Get_Line, Last and slices to read several times into the
same string object at different positions.

But that doesn't seem like it would entirely do what you want, because as
you may not have noticed, a String is not dynamic - it has a fixed size that
you will eventually exhaust if you keep concatenating to it in a loop.

What may be more useful is to investigate Unbounded_String. (See: ARM
Appendix A.4.5) You can take a String and concatenate to the end of an
Unbounded_String (as well as many other operations) and then the string can
keep growing until you exhaust available memory.

You'll find it really helpful when dealing with strings to look over the
predefined string handling packages that Ada provides. Check out the
appendices of the ARM or a good Ada book to find all the help Ada gives you
with this.

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/


"Anthony Wise" <iamwisey_@hotmail.com> wrote in message
news:mailman.1013706303.15083.comp.lang.ada@ada.eu.org...
> Hi
> another newbie question !
>
> I need my program to be able to accept lines of text.  These lines can be
as
> long or short as the user likes.
> I am using the Get_Line procedure (Using only one string), however this
> allows only one entery.  So i put Get_Line in a loop, but now the only
> accessable input is the last input.  Is there anyway i can store all the
> inputs so i can process  them and then output them all together.
> all advice welcomed thx.
>
> _________________________________________________________________
> MSN Photos is the easiest way to share and print your photos:
> http://photos.msn.com/support/worldwide.aspx
>





  reply	other threads:[~2002-02-14 18:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-14 17:04 Storing A string Anthony Wise
2002-02-14 18:07 ` Marin David Condic [this message]
2002-02-14 18:23 ` Matthew Heaney
2002-02-15 13:05 ` Marc A. Criley
     [not found] <F14ETmXuldbjZj8RfDy00001fdf@hotmail.com>
2002-02-21 12:21 ` M. A. Alves
replies disabled

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