[Gambas-user] reopen standard input

nando nando_f at ...951...
Fri May 30 03:53:06 CEST 2008


I believe you get the EOF error because your program is wanting input
there isn't any from the sending program (through the pipe).
STDIN is always open.
You have to make sure your program won't crash due to no input available
which is what is happening here.
Data is sent through the pipe when the kernel does it, and it may not
necessarily be on a word or a line boundaries and you might believe.
Expect that the input line could have no data.
-Fernando




---------- Original Message -----------
From: Robin Thompson <robane00 at ...67...>
To: <gambas-user at lists.sourceforge.net>
Sent: Thu, 29 May 2008 20:45:56 +0000
Subject: [Gambas-user] reopen standard input

> Hi,
> 
> I'm trouble with a console program i'm writing.  Basically it requires user 
> input from the console.  But the program itself is run from a pipe
> 
> i.e cmd1 | myprog.gambas
> 
> PUBLIC SUB Main()
> DIM a AS Integer
> DIM inputline AS NEW String[]
> DIM ipt, f AS String
> a = -1
> 
> WHILE NOT Eof(file.in)   
> a += 1
> inputline.Resize(a + 1)
> LINE INPUT #file.In, inputline[a] 
> WEND
> 
> FOR EACH f IN inputline
> 
> LINE INPUT ipt  < --  at this point i get MMain.Main.21: #39: End of file
> PRINT #file.out, f & " " & ipt
> 
> NEXT 
> END
> 
> How do I "reopen" standard input?
> 
> Thanks,
> 
> RT
> _________________________________________________________________
> 
> http://clk.atdmt.com/UKM/go/msnnkmgl0010000009ukm/direct/01/
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------





More information about the User mailing list