comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: Newbie Question: using Text_IO.Open() to read from standard input
Date: Wed, 12 Oct 2005 20:15:10 -0700
Date: 2005-10-12T20:15:10-07:00	[thread overview]
Message-ID: <BKudnVW0r6FyTdDeRVn-hA@comcast.com> (raw)
In-Reply-To: 1129164557.586640.154480@g14g2000cwa.googlegroups.com

<pamela.lum@gmail.com> wrote in message 
news:1129164557.586640.154480@g14g2000cwa.googlegroups.com...
> Hi,
>
> I need to open a file that is passed to my ada executable as standard
> input, in the following fashion:
>
> ./myprogram < inputfile.txt
>
> My question is: How can i get the Open() function to open a file from
> standard input so that I can bypass using a static file name? For
> example:
>
> Integer_File : FILE_TYPE;
> Open(Integer_File, In_File, "inputfile.txt"); <-- don't open
> inputfile.txt, open file from standard input instead
>
> I know that this can be done easily with Ada.Text_IO.Text_Streams,
> however I am stubborn and curious to see if there is a simple and easy
> way to do it with the Open() function.
>
> THanks
>
The following simple example works on red hat linux 8.0

with Ada.Text_IO;

procedure TestPassThru is
  package Text_IO renames Ada.Text_IO;
begin
  while not Text_IO.End_Of_File loop
    declare
        text : String( 1 .. 255 );
        last : Natural;
    begin
       Text_IO.Get_Line( text, last );
       Text_IO.Put_Line( text( 1 .. last ) );
    end;
  end loop;
end TestPassThru;

(Sorry for any typo's I had to copy the code from one screen to another).

Steve
(The Duck)





      parent reply	other threads:[~2005-10-13  3:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-13  0:49 Newbie Question: using Text_IO.Open() to read from standard input pamela.lum
2005-10-13  1:30 ` Anh Vo
2005-10-13  1:48   ` pamela.lum
2005-10-13  1:56     ` Anh Vo
2005-10-13 16:14     ` Martin Krischik
2005-10-13  1:58 ` tmoran
2005-10-13  2:02   ` pamela.lum
2005-10-13  2:19     ` Anh Vo
2005-10-13  5:26   ` Jeffrey R. Carter
2005-10-13  6:53     ` tmoran
2005-10-13  3:15 ` Steve [this message]
replies disabled

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