On Thu, Aug 30, 2018 at 09:45:00AM +0000, Mark Morgan Lloyd wrote:
> On 30/08/18 09:00, Henry Vermaak wrote:
> >On Thu, Aug 30, 2018 at 07:52:54AM +0200, Martin Schreiber wrote:
>
> >In order to flush textfiles automatically I use> ">
> >ttextrec(<thefile>).flushfunc:= ttextrec(<thefile>).inoutfunc;> "> after it
> >is opened.
>
> >Reading text.inc this morning lead me to believe this is the correctway.
> >This is what the RTL does when opening serial devices inFileOpenFunc(), for
> >example. There's a comment inside Flush() that saysthat InOutFunc() should
> >be used to flush, since the FlushFunc() may notbe assigned.
>
> I've just checked this and unfortunately it doesn't do very much for the
> standard device (?) used by WriteLn() etc., i.e. as would be used for a
> quick-and-dirty program.
It definitely works for me. I made a program flush.pas that looks like this:
begin
ttextrec(output).flushfunc := ttextrec(output).inoutfunc;
writeln('hi there');
sleep(1000);
end.
Running `./flush > out.txt` and `tail -F out.txt` shows the output
immediately, while removing the flushfunc assignment causes a delay of a
second before the output appeared in the file.
Henry
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal