comp.lang.ada
 help / color / mirror / Atom feed
* How to detect new line from std_in?
@ 1998-04-15  0:00 Centaury
  1998-04-16  0:00 ` Stephen Leake
  0 siblings, 1 reply; 3+ messages in thread
From: Centaury @ 1998-04-15  0:00 UTC (permalink / raw)



I'm writing a program that reads text from std_in whether by keyboard entry
or file redirection.
If I have something that looks like this;

harlooo and welcome to
the greatest circus

my program would only recognise that there is 6 words, instead of 7. This is
because to and the are joined together and become tothe as the data in my
linked list.

What is the keyword to detect new line (or is it something else??)

Please reply

Regards,

Centaury






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

* Re: How to detect new line from std_in?
  1998-04-15  0:00 Centaury
@ 1998-04-16  0:00 ` Stephen Leake
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Leake @ 1998-04-16  0:00 UTC (permalink / raw)



Centaury wrote:
> 
> I'm writing a program that reads text from std_in whether by keyboard entry
> or file redirection.
> If I have something that looks like this;
> 
> harlooo and welcome to
> the greatest circus
> 
> my program would only recognise that there is 6 words, instead of 7. This is
> because to and the are joined together and become tothe as the data in my
> linked list.
> 
> What is the keyword to detect new line (or is it something else??)

If you are using Ada.Text_IO, there is no "keyword" for the end of line.
Text_IO is a line-oriented view of a file; you have to read the file
with Get_Line, and keep track of line breaks yourself.

If you are reading the file with Stream_IO, then you should see some
character(s) representing the line break, but this is operating system
(and editor!) dependent.

-- 
- Stephe




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

* Re: How to detect new line from std_in?
@ 1998-04-17  0:00 Marin David Condic, 561.796.8997, M/S 731-96
  0 siblings, 0 replies; 3+ messages in thread
From: Marin David Condic, 561.796.8997, M/S 731-96 @ 1998-04-17  0:00 UTC (permalink / raw)



Centaury <utopian@TM.NET.MY> writes:
>I'm writing a program that reads text from std_in whether by keyboard entry
>or file redirection.
>If I have something that looks like this;
>
>harlooo and welcome to
>the greatest circus
>
>my program would only recognise that there is 6 words, instead of 7. This is
>because to and the are joined together and become tothe as the data in my
>linked list.
>
>What is the keyword to detect new line (or is it something else??)
>
    It sounds like you are reading the input a byte at a time with the
    "Get" procedure and, given its semantics, it bypasses the end of
    line marker and starts at the next line of input. You should take
    a serious look at the package Ada.Text_IO. It might suggest easier
    ways to do this, such as reading in a whole line at a time and
    concatenating lines if you want to process the input as a
    character at a time.

    But, given that you want to look at it a character at a time, you
    will want to look up these functions in Ada.Text_IO: End_Of_Line,
    End_Of_Page and End_Of_File. If you're reading a character at a
    time, you probably need to look at all these functions to know
    when to stop.

    MDC

Marin David Condic, Senior Computer Engineer     Voice:     561.796.8997
Pratt & Whitney GESP, M/S 731-95, P.O.B. 109600  Fax:       561.796.4669
West Palm Beach, FL, 33410-9600                  Internet:  CONDICMA@PWFL.COM
=============================================================================
    "Because that's where they keep the money."
        --  Willie Sutton when asked why he robbed banks.
=============================================================================




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

end of thread, other threads:[~1998-04-17  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-17  0:00 How to detect new line from std_in? Marin David Condic, 561.796.8997, M/S 731-96
  -- strict thread matches above, loose matches on Subject: below --
1998-04-15  0:00 Centaury
1998-04-16  0:00 ` Stephen Leake

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