comp.lang.ada
 help / color / mirror / Atom feed
From: "M. A. Alves" <maa@liacc.up.pt>
Subject: Re: Storing A string
Date: Thu, 21 Feb 2002 12:21:08 +0000 (GMT)
Date: 2002-02-21T12:21:08+00:00	[thread overview]
Message-ID: <mailman.1014294062.26976.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: <F14ETmXuldbjZj8RfDy00001fdf@hotmail.com>

On Thu, 14 Feb 2002, Anthony Wise wrote:
> I need my program to be able to accept lines of text. [1] These lines
> can be as long or short as the user likes. [2] I am using the Get_Line
> procedure (Using only one string)

Note that, in rigour, [1] and [2] are incompatible, since a String has
limited length.

However we can assume a big limit = no limit in practice, and for
expository purposes of the next question.

> , 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.

Store where? In main memory? Sure. Since we are already in a 'limits'
idiom, I suggest an array of Unbounded_String e.g. (not tested):

  Line_Buffer : String (1 .. 1000);
  Line_Length : Natural range 0 .. Line_Buffer'Last;
  Line_Store  : array (1 .. 10_000) of Unbounded_String;
  Line_Count  : Natural range 0 .. Line_Store'Last;
begin
  loop
    Get_Line (Line_Buffer, Line_Length);
    Line_Count := Line_Count + 1;
    Line_Store (Line_Count) :=
      To_Unbounded_String (Line_Buffer (1 .. Line_Length));
    ... -- some exit condition here
  end loop;
  -- 'output them all together' (?) here

-- 
   ,
 M A R I O   data miner, LIACC, room 221   tel 351+226078830, ext 121
 A M A D O   Rua Campo Alegre, 823         fax 351+226003654
 A L V E S   P-4150-180 PORTO, Portugal    mob 351+939354002





       reply	other threads:[~2002-02-21 12:21 UTC|newest]

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

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