reading standard input

Linux specific questions.
Post Reply
dbickin
Posts: 59
Joined: Aug 03, 2005 16:40

reading standard input

Post by dbickin »

I should know this, but I am having a very senior moment here....

I want to run some commands
prog1 | fb-prog | prog3

That is, I want my freebasic program to read the output of prog1, process the data line by line, then write the results out so prog3 can process it.

I can do a do loop of line input to read the input, but how do i terminate the do loop? There is no file number involved, so I can't use the eof function.

Pseudocode of what I want to do.

Code: Select all

do
   line input b
   if test(b) is true
     write line of output
   end if
loop
What obvious thing am I missing here?

Thanks,
David
SARG
Posts: 1768
Joined: May 27, 2005 7:15
Location: FRANCE

Re: reading standard input

Post by SARG »

Does prog1 can send something like "END OF DATA" ?
In this case you can use

Code: Select all

 if b = "END OF DATA"  then exit do
angros47
Posts: 2326
Joined: Jun 21, 2005 19:04

Re: reading standard input

Post by angros47 »

It's explained here:
viewtopic.php?t=3678

Basically, use "Open Cons" and then you are allowed to use the EOF function
dbickin
Posts: 59
Joined: Aug 03, 2005 16:40

Re: reading standard input

Post by dbickin »

angros47 wrote: Aug 03, 2023 7:55 Basically, use "Open Cons" and then you are allowed to use the EOF function
Thanks, that is the obvious thing I missed. Actually I thought for sure I checked out Open Cons and what I read made me think it wouldn't work, but I have no idea what I had read that made me think that. I need to stop trying to code at 2am.

David
Post Reply