next up previous index
Next: Loading Tcl/Tk Scripts Up: Using Tcl/Tk from Previous: Implicit Data Conversion

Explicit Conversion

The predicate

tcl_string(Term, TclString)  
can be used to explicitly convert any Prolog term to a corresponding Tcl string:  
[eclipse 18]: tcl_string([a, b, c], X).

X = " {a b c}"
yes.
In this case, more data processing is performed and so more data types can be converted to Tcl, in particular bignums and rationals.    
[eclipse 20]: tcl_string([2_3, ["a b c", 2347236456534, []], 3.15e+14], S).

S = " {0.666666687  {{a b c} 2.34723633e+12 {}} 3.15e+14}"
yes.
This predicate is mainly used to pass Prolog lists to Tcl commands with tcl/2  , e.g.  
[eclipse 8]: tcl_string([a, b, c], L),
        tcl('foreach w ## {toplevel .$w}', [L]).

L = " {a b c}"
yes.
The main use of this predicate consists of passing Prolog lists to Tcl commands with tcl/2  .



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