Reputation: 69
I'm having a very hard time debugging my code with gprolog, does anyone know how to print the value of a variable to the console after I've compiled it? I've tried using print, write and trace within my code but none have had any consequence, not even an error. Please help!
Upvotes: 2
Views: 1749
Reputation: 60004
session example: start gprolog in console
GNU Prolog 1.3.0
By Daniel Diaz
Copyright (C) 1999-2007 Daniel Diaz
| ?- [user].
compiling user for byte code...
test_pos(P) :- P > 0 -> true ; format('~w is invalid', [P]).
user compiled, 2 lines read - 762 bytes written, 180411 ms
(8 ms) yes
| ?- trace,test_pos(-3).
The debugger will first creep -- showing everything (trace)
1 1 Call: test_pos(-3) ?
2 2 Call: -3>0 ?
2 2 Fail: -3>0 ?
2 2 Call: format('~w is invalid',[-3]) ?
-3 is invalid
2 2 Exit: format('~w is invalid',[-3]) ?
1 1 Exit: test_pos(-3) ?
yes
{trace}
| ?-
before the message user compiled,...
I entered Ctrl-D to force compilation
HTH
Upvotes: 1