Nihlius
Nihlius

Reputation: 89

Write immediatly on the console

I want to abort my program right after it writes something to the console, but "write" is not displaying the message immediatly.

write('The AI wins!'), abort.

This is the message I want to be shown. I tried it with "print" and it stays the same. I also tried it with "flush_output" but it gives an error message, that says "stream 'The AI wins!'" does not exist!".

Is there a way to display the message immediatly?

Upvotes: 1

Views: 44

Answers (1)

CapelliC
CapelliC

Reputation: 60004

Try flushing before of abort/0. I think write/1 it's not flushing the output and it get lost by abort/0, that throws a specific exception for console interaction. Indeed

?- write('The AI wins!'), flush_output, abort.
The AI wins!
% Execution Aborted

Upvotes: 1

Related Questions