Question: How to perform immediate output from a procedure?

f:=proc ()
local s;
s := time();
FileTools[Text][WriteString]('default', "a");
FileTools[Flush]('default');
while time() < s+20 do  end do
end proc;
f();

 

In the codes above, I intended that the string "a" is outputed immediately after the function FileTools[Text][WriteString] is called.  But in execution, the output does not appear until 20 seconds elapse.

How can I force the output appear immediately?

In fact, I have a long program from which I expect fast progress reports, but due to the phenomenon above, the reporting cycles are not satisfactory (too long).

Please Wait...