[Gambas-user] PIPE issues
Benoît Minisini
gambas at ...1...
Mon Dec 13 22:22:41 CET 2010
> >
> > 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,
--
Benoît Minisini
More information about the User
mailing list