On dimanche 12 octobre 2008, Benoit Minisini wrote: > On dimanche 12 octobre 2008, Doriano Blengino wrote: > > Tell me what your tests say to you - this is very interesting because I > > did not try if that book was true or not. > > Strange behaviours. > > If I replace INPUT OUTPUT by READ WRITE, the process does not write to its > standard output anymore. > > But if I replace the "tr" program by "cat", then READ WRITE works as > expected. > > So there is something different in "tr" that prevents him to work with the > READ WRITE options. > > Moreover, sometimes the first write to the "tr" process fails (with a bad > file descriptor error message). > > All that needs some investigation... > > Regards,
OK, I think I have understoood. The behaviour is normal (except the 'bad file descriptor' error message). Try that in a shell: $ cat | tr "a-z" "A-Z" > tr.out This is an equivalent of what you tried to do in your program. Some things are sent to the input of "tr" line by line, and the output is put somewhere (inside a file in that case). I looked inside the source code of tr, and this tool uses buffered output. So: - If the output of 'tr' is a terminal (this is the case when you use INPUT OUTPUT in Gambas), then 'tr' output is automatically flushed at each end of line. - Otherwise, output is flushed when the buffer is full, i.e. when 'tr' has 4096 bytes to write. You see that in the shell command above. While you have not entered at least 4096 bytes, nothing is write in the tr.out file. I hope I was clear! Regards, -- Benoit Minisini ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user