comp.lang.ada
 help / color / mirror / Atom feed
From: Marius Amado Alves <amado.alves@netcabo.pt>
To: comp.lang.ada@ada-france.org
Subject: Re: Random Input-Size and recognizing ENTER-press
Date: Sun, 19 Dec 2004 14:50:45 +0000
Date: 2004-12-19T14:50:45+00:00	[thread overview]
Message-ID: <mailman.203.1103467874.10401.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <cq3f0i$fau$05$1@news.t-online.com>

> I need to to Get() a random number of characters (typed by the user) in 
> an array.
> I could loop with a Get() statement and exit when all the inputs are in 
> the array, but for that I'd need to know the number of inputs before.

If this is your only problem then it its no problem. Use an unbounded 
array. For characters that would be an Unbounded_String.

And use Get_Immediate if you want to test explicitly for CR (as the 
usual representation of Enter).

Since you say you want an array (for characters that would be a String), 
encapsulate the reading procedure inside a function returning a String.

On a silver plater:

    function Get_String return String is
       U : Unbounded_String;
    begin
       loop
          Get_Immediate (C);
          exit when C = CR;
          Append (U, C);
       end loop;
       return To_String (U);
    end;





  reply	other threads:[~2004-12-19 14:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-19  8:44 Random Input-Size and recognizing ENTER-press xadian
2004-12-19 14:50 ` Marius Amado Alves [this message]
2004-12-19 16:01   ` Jeffrey Carter
2004-12-19 16:03     ` Pascal Obry
2004-12-19 23:47       ` Jeffrey Carter
2004-12-20 14:36     ` Steve
2004-12-20 23:45       ` Jeffrey Carter
2004-12-19 15:52 ` Jeffrey Carter
replies disabled

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