Flush output stream before waiting for user input.

This commit is contained in:
dtrg 2010-08-05 22:23:34 +00:00
commit da6111328d

View file

@ -6,13 +6,22 @@
MODULE HiLo; MODULE HiLo;
FROM InOut IMPORT WriteInt, WriteLn, WriteString, ReadString, ReadInt; FROM InOut IMPORT WriteInt, WriteLn, WriteString, ReadString, ReadInt;
FROM random IMPORT Uniform; FROM random IMPORT Uniform;
FROM Streams IMPORT FlushStream, OutputStream, StreamResult;
VAR VAR
buffer : ARRAY [0..32] OF CHAR; buffer : ARRAY [0..32] OF CHAR;
PROCEDURE flush;
VAR
strus : StreamResult;
BEGIN
FlushStream(OutputStream, strus);
END flush;
PROCEDURE reads; PROCEDURE reads;
BEGIN BEGIN
WriteString("> "); WriteString("> ");
flush;
ReadString(buffer); ReadString(buffer);
END reads; END reads;
@ -31,8 +40,8 @@ BEGIN
finished := FALSE; finished := FALSE;
WHILE NOT finished DO WHILE NOT finished DO
WriteLn;
WriteString("> "); WriteString("> ");
flush;
ReadInt(guess); ReadInt(guess);
IF guess = Number THEN IF guess = Number THEN