Flush output stream before waiting for user input.
This commit is contained in:
commit
da6111328d
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue