[Gambas-user] PIPE issues

Demosthenes Koptsis demosthenesk at ...626...
Wed Dec 15 11:40:00 CET 2010


Thanks Benoît!

On Mon, 2010-12-13 at 22:22 +0100, Benoît Minisini wrote:
> > > 
> > > This is a pipe. Data is available only when it has been filled by the
> > > other side. So Eof() can returns true at anytime, even if some data may
> > > be written in the future. Gambas cannot read the future yet.
> > 
> > Benoit, i got this example from the wiki.
> > http://gambasdoc.org/help/lang/pipe?v3
> 
> Then the example is wrong. I don't think I wrote it anyway.
> 
> > 
> > > > if i change to
> > > > WHILE TRUE
> > > > 
> > > > i get the ls results to console and
> > > > i get an error
> > > > 
> > > > System error. Inappropriate ioctl for device.
> > > 
> > > The error message is not very accurate. But it is normal, as reading on a
> > > pipe that has been closed on the other side is impossible.
> > > 
> > > Regards,
> > 
> > What is the right code to read a pipe if it is not with Eof() or WHILE
> > TRUE ?
> > 
> > 
> > Thanks Benoit for your answer.
> 
> In Gambas 2, you must do something like that:
> 
>   DIM hFile AS File
>   DIM sLine AS String
>   
>   hFile = PIPE "/tmp/FIFO1" FOR READ
>   
>   DO
>     TRY READ #hFile, sLine, -256
>     IF NOT sLine THEN BREAK
>     PRINT sLine;
>   LOOP
> 
> In Gambas 3, you can do that too:
> 
>   Dim hFile As File
>   Dim sLine As String
>   
>   hFile = Pipe "/tmp/FIFO1" For Read
>   
>   Do
>     Line Input #hFile, sLine
>     If hFile.EndOfFile Then Break
>     Print sLine
>   Loop
> 
> Regards,
> 

-- 
Regards,
Demosthenes Koptsis.





More information about the User mailing list