To save a record of program execution in prolog, we use the special predicates: protocol and noprotocol. Like this:

 

protocol(‘execution.txt’).

 

noprotocol.

 

All the queries and their responses between the protocol and noprotocol will be saved to this file.

 

If we use these predicates, we will get records like this:

 

11 ?- beside(block2, X).

X = block3  [1m;[0m

[1;31mfalse.[0m

 

12 ?- beside(block4, X).

X = block7  [1m;[0m

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.

 

 posted on 2013-11-11 23:03  Jiang, X.  阅读(360)  评论(0编辑  收藏  举报