Node:Generic Tcl/Tk problems, Previous:Compiling SICStus with Tcl/Tk support, Up:Interfacing with Tcl/Tk



Generic Tcl/Tk problems

Question:
I get the message "tcl_new/1 - Can't find a usable init.tcl in the following directories..."

This means that Tcl/Tk can't find its libraries of tcl-code needed for operation. This occurs when Tcl/Tk has been built but not properly installed. You have the option of stating the location of the libraries by means of the environment variables TCL_LIBRARY and TK_LIBRARY. See also the Tcl/Tk documentation.

Another reason for this could be if you are not using SICStus 3.8.1 or later. The original SICStus 3.8 did not initialize Tcl/Tk correctly.

Question:
I get the message "tcl_eval/3 - can't read `var(Tree)': no such variable"

This message can appear in Tcl code which tries to access Prolog variables. Example:

     tk_test :-
         tk_new([],Interp),
         tcl_eval(Interp,
                  '
                   global var
                   set Tree []
                   set Children []
                   set GrandChildren []
                   prolog {get_tree(Tree),
                          make_children(Tree, Children),
                          make_grandChildren(Tree, Children, GrandChildren)}
                   puts "$var(Tree) $var(Children) $var(GrandChildren) "
                   ', _),
         tk_main_loop,
         tcl_delete(Interp).
     

The problem is that the argument to the prolog function is just a string that is interpreted by Prolog as a goal. There is no connection between the Prolog variables Tree, Children and GrandChildren and the Tcl-variables with the same name. After returning from prolog, the values which the Prolog variables have been bound to are assigned to the array variable prolog_variables.

So replacing $var in your example with $prolog_variables, makes it work.