comp.lang.ada
 help / color / mirror / Atom feed
* string input
@ 2001-11-26  9:45 kotee
  2001-11-26 14:49 ` Alfred Hilscher
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: kotee @ 2001-11-26  9:45 UTC (permalink / raw)


helo

what can i do if i wanna read user input to a string with
length short (i wanna do it in loop), and user write a
very long string. if it happens the next and the next...
input is filled with that trash of first input...
pls hlp

kotee



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: string input
  2001-11-26  9:45 string input kotee
@ 2001-11-26 14:49 ` Alfred Hilscher
  2001-11-26 16:51   ` Jeffrey Carter
  2001-11-26 17:16   ` kotee
  2001-11-26 15:11 ` Matthew Heaney
  2001-11-27  4:05 ` Robert Dewar
  2 siblings, 2 replies; 8+ messages in thread
From: Alfred Hilscher @ 2001-11-26 14:49 UTC (permalink / raw)




kotee@ludens.elte.hu wrote:
> 
> helo
> 
> what can i do if i wanna read user input to a string with
> length short (i wanna do it in loop), and user write a
> very long string. if it happens the next and the next...
> input is filled with that trash of first input...
> pls hlp
> 
> kotee

Your looking for Skip_Line ?



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: string input
  2001-11-26  9:45 string input kotee
  2001-11-26 14:49 ` Alfred Hilscher
@ 2001-11-26 15:11 ` Matthew Heaney
  2001-11-27  4:05 ` Robert Dewar
  2 siblings, 0 replies; 8+ messages in thread
From: Matthew Heaney @ 2001-11-26 15:11 UTC (permalink / raw)



<kotee@ludens.elte.hu> wrote in message news:GhByriDlSyh1@ludens...
> helo
>
> what can i do if i wanna read user input to a string with
> length short (i wanna do it in loop), and user write a
> very long string. if it happens the next and the next...
> input is filled with that trash of first input...

You can either use a loop, and copy the short string into a longer buffer
(say, an Unbounded_String); or, you could use a recursive solution.

The idiom for reading lines of text in Ada is:

declare
   Line : String (1 .. 10); --say
  Last : Natural;
begin
  loop
     Text_IO.Get_Line (Line, Last);
     <copy Line to an Unbounded_String>
     exit when Last < Line'Last;
   end loop;
end;

That should give you enough info to get started.






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: string input
  2001-11-26 14:49 ` Alfred Hilscher
@ 2001-11-26 16:51   ` Jeffrey Carter
  2001-11-26 17:16   ` kotee
  1 sibling, 0 replies; 8+ messages in thread
From: Jeffrey Carter @ 2001-11-26 16:51 UTC (permalink / raw)


Alfred Hilscher wrote:
> 
> kotee@ludens.elte.hu wrote:
> >
> > what can i do if i wanna read user input to a string with
> > length short (i wanna do it in loop), and user write a
> > very long string. if it happens the next and the next...
> > input is filled with that trash of first input...
> > pls hlp
> >
> > kotee
> 
> Your looking for Skip_Line ?

Or perhaps a function such as PragmARC.Get_Line.

-- 
Jeffrey Carter



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: string input
  2001-11-26 14:49 ` Alfred Hilscher
  2001-11-26 16:51   ` Jeffrey Carter
@ 2001-11-26 17:16   ` kotee
  1 sibling, 0 replies; 8+ messages in thread
From: kotee @ 2001-11-26 17:16 UTC (permalink / raw)


In article <3C025666.4108D449@icn.siemens.de>, Alfred Hilscher <Alfred.Hilscher@icn.siemens.de> writes:
> kotee@ludens.elte.hu wrote:
>> 
>> helo
>> 
>> what can i do if i wanna read user input to a string with
>> length short (i wanna do it in loop), and user write a
>> very long string. if it happens the next and the next...
>> input is filled with that trash of first input...
>> pls hlp
>> 
>> kotee
> 
> Your looking for Skip_Line ?
yes! :))))



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: string input
  2001-11-26  9:45 string input kotee
  2001-11-26 14:49 ` Alfred Hilscher
  2001-11-26 15:11 ` Matthew Heaney
@ 2001-11-27  4:05 ` Robert Dewar
  2001-11-27  6:25   ` Mark Lundquist
  2 siblings, 1 reply; 8+ messages in thread
From: Robert Dewar @ 2001-11-27  4:05 UTC (permalink / raw)


kotee@ludens.elte.hu wrote in message news:<GhByriDlSyh1@ludens>...
> helo
> 
> what can i do if i wanna read user input to a string with
> length short (i wanna do it in loop), and user write a
> very long string. if it happens the next and the next...
> input is filled with that trash of first input...
> pls hlp
> 
> kotee

Note that if you are using GNAT, the function
Ada.Strings.Unbounded.Get_Line is very convenient
for reading strings of varying length.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: string input
  2001-11-27  4:05 ` Robert Dewar
@ 2001-11-27  6:25   ` Mark Lundquist
  2001-11-27  9:33     ` Lutz Donnerhacke
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Lundquist @ 2001-11-27  6:25 UTC (permalink / raw)



"Robert Dewar" <dewar@gnat.com> wrote in message
news:5ee5b646.0111262005.74c646cc@posting.google.com...

> Note that if you are using GNAT, the function
> Ada.Strings.Unbounded.Get_Line is very convenient
> for reading strings of varying length.

I believe it's Ada.Strings.Unbounded.Text_Io.Get_Line

-- mark






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: string input
  2001-11-27  6:25   ` Mark Lundquist
@ 2001-11-27  9:33     ` Lutz Donnerhacke
  0 siblings, 0 replies; 8+ messages in thread
From: Lutz Donnerhacke @ 2001-11-27  9:33 UTC (permalink / raw)


* Mark Lundquist wrote:
>"Robert Dewar" <dewar@gnat.com> wrote in message
>> Note that if you are using GNAT, the function
>> Ada.Strings.Unbounded.Get_Line is very convenient
>> for reading strings of varying length.
>
>I believe it's Ada.Strings.Unbounded.Text_Io.Get_Line

GNAT tends to use recursion, which is known to genereate problems.
 Problematic version:
   http://www.iks-jena.de/mitarb/lutz/ada/reverse_line_tokens__adb.htm
 Scalable version:
   http://www.iks-jena.de/mitarb/lutz/ada/shuffle_text_tokens__adb.htm




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-11-27  9:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-26  9:45 string input kotee
2001-11-26 14:49 ` Alfred Hilscher
2001-11-26 16:51   ` Jeffrey Carter
2001-11-26 17:16   ` kotee
2001-11-26 15:11 ` Matthew Heaney
2001-11-27  4:05 ` Robert Dewar
2001-11-27  6:25   ` Mark Lundquist
2001-11-27  9:33     ` Lutz Donnerhacke

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