next up previous index
Next: Accessing Prolog Variables Up: Calling Prolog from Previous: Calling Prolog from

Returning Values to Tcl

A Prolog predicate may succeed, fail or exit using exit_block/1  . The prolog   command returns a string success, fail or error depending on the result of the Prolog call:

[eclipse 19]: tclsh.
% prolog true
success
% prolog fail
fail
% prolog "exit_block 1"
error
%

The Prolog goal can also contain Prolog variables:   top level arguments of Prolog predicates called from Tcl, which start with an upper case character, are interpreted and passed to Prolog as variables:

[eclipse 23]: tclsh.
% prolog "var X"
success
Note that this is the case only for top level arguments of Prolog predicates; list arguments are passed as strings:
[eclipse 15]: tclsh.
% prolog {printf "%Qw%n" A}
_366
success
% prolog {printf "%Qw%Qw%Qw%n" {A B C}}
"A""B""C"
success


Micha Meier
Tue Jul 2 09:49:39 MET DST 1996