To save a record of program execution in prolog, we use the special predicates: protocol and noprotocol. Like this:bash
protocol(‘execution.txt’).session
noprotocol.ide
All the queries and their responses between the protocol and noprotocol will be saved to this file.this
If we use these predicates, we will get records like this:spa
11 ?- beside(block2, X).code
X = block3 [1m;[0mip
[1;31mfalse.[0mci
12 ?- beside(block4, X).terminal
X = block7 [1m;[0mget
X = block3 [1m;[0m
[1;31mfalse.[0m
The characters [1m [0m looks like garbage characters but they are ANSI terminal codes. We can get the reference from here:
http://wiki.bash-hackers.org/scripting/terminalcodes
As we can see from the link above, [0m refers to reset all attributes and [1m refers to set bright attribute.
If we want to disable these codes, we can use predicate: set_prolog_flag(color_term, false). before starting the protocol session.