[Gambas-user] about process

Benoit Minisini gambas at ...1...
Sun Dec 7 13:01:45 CET 2003


On Sunday 07 December 2003 10:45, Edward Hsu wrote:
> Dear Ron and Benoit,
>
> Thanks for the helpful e-mails about EXEC with READ
> option for the mplayer. It is working fine with Gambas
> 0.73.
>
> It is right as Ron said we have to use line input in
> Process_Read function. I used Read #$hProcess, sData,
> and it doesn't work at all, when I changed to Line
> Input #$hProcess, sData then it works beautifully.
>
> Regards,
>
> Edward
>

You must understand carefully what LINE INPUT and READ do.

LINE INPUT reads a stream until a '\n' character or an end of file, and 
returns what it reads as as string. Use it if you are sure that your process 
sends only text lines (it is a common behaviour with UNIX commands).

READ #Stream, sData reads a string on the stream in a GAMBAS serialized 
format: in other words, it reads the length of the string first, and then 
reads the string itself. You use this function only if you read a stream 
where you wrote data with WRITE #Stream, sData.

Elsewhere, you can use the following syntax: READ #Stream, sData, N
Then, you will just read N characters on the stream as a string. Or you can 
use READ #Stream, sData, -N. Then, you will read N characters on the stream, 
or less if a end of file happens. I use that to read the output of a process 
in the IDE debugger.

I hope everything is clearer.

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...





More information about the User mailing list