next up previous index
Next: Xlib Predicates Up: ProTcXl 2.1 User Previous: Other Information Sources

ProTcXl Prolog Predicates

   
tcl +Script
invokes the Tcl interpreter to evalue the Script, which can be an atom or a string. The value returned by the Tcl interpreter is ignored.

 

tcl(+Script, +Vars)
invokes the Tcl interpreter to evaluate the Script, which can be an atom or a string. Before passing to Tcl, all occurrences of the string ## in the script are substituted by consecutive elements of the list Vars.   For example, if the predicate
draw_box(X1, Y1, X2, Y2, Col) :-
    tcl('canvas .c; .c create rectangle ## ## ## ## -fill ##',
        [X1, Y1, X2, Y2, Col]).
is called as
draw_box(10, 10, 20, 30, red)
then the Tk command
canvas .c; .c create rectangle 10 10 20 30 -fill red
will be executed.

 

tcl(+Script, +Vars, ?Result)
Similar to tcl/2  , but the resulting value of the Tcl command is unified with Result. If Result is string(Res1), the resulting Tcl value will be converted to a Prolog string, no matter if it corresponds to a Tcl list or not, and unified with Res1.

 

tcl_cut_fail(+Script)
This predicate remembers the Tcl/Tk script Script in an ECLiPSe internal data structure (the trail). If later this predicate is being cut or if the Prolog execution fails over it, this script is executed. A typical usage for this predicate is to restore the display state after the alternative clause of a deamon has been removed by   a cut and/or failed over.

 

tcl_eval(+Script)
A synonym for tcl_eval(Script, _), it is used to execute a Tcl script whose resulting value is not significant. Script may be an atom, string, or a list of atomic terms. This predicate is obsolete and superseeded by tcl/1   and tcl/2  .

 

tcl_eval(+Script, -Result)
It invokes a Tcl interpreter to evaluate the Script and its resulting value is unified with Result. If Result is string(Res1), the resulting Tcl value will be converted to a Prolog string, no matter if it corresponds to a Tcl list or not, and unified with Res1. Script may be an atom, a string or a list of atomic terms. In the latter case, all elements of the list are concatenated into one string which is then passed as a command to the Tcl interpreter. This predicate is obsolete and superseeded by tcl/3  .

 

tcl_interp(-Interp)
  Interp will be unified with the (integer) value of the current Tcl interpreter. This value can be used in calls to internal Tcl and Tk functions with call_c/2 or to initialise extensions. For example:
[eclipse 3]: tcl_interp(I), call_c('Tcl_GetVar'(I,"tcl_version",0), string(S)).

I = 1701496
S = "7.4"
yes.

 

tcl_source
When this predicate is called, it defines a new predicate tcl_source/1   in the current module which can be used to read in Tcl/Tk script files from the directory where tcl_source/0 has been called. The main use of this predicate is to call it as a query inside a Prolog file which is the part of a package written in Prolog and Tcl/Tk. Then, no matter from which directory the Prolog file was compiled, the Tcl/Tk source files will be accessed in the same directory as the Prolog file. When tcl_source/0 is called from different modules, it creates different versions of tcl_source/1   in these modules.

 

tcl_source(+TclFile)
This predicate is available if tcl_source/0   has been called before. It executes the Tcl command
source   Dir/TclFile
where Dir is the directory in which tcl_source/0   has been called. The purpose of this predicate is to achieve a behaviour similar to ECLiPSe 's compilation, where the path to a recursively compiled file is taken relative to the current file rather than to the current working directory.

 

tcl_string(+Term, -String)
The Prolog term Term is converted to the corresponding     Tcl string format. The Prolog types are converted as follows: This predicate is typically used to convert Prolog lists to the Tcl format and pass them as arguments to Tcl commands in tcl/2  .

 

tclsh
A tclsh-like interpreter loop will be started. If Tcl is not running, it will be started using
tk([nodisplay]).
The loop behaves very much like the Tcl tclsh   program, it prints the prompt, reads user input and executes it as a Tcl command. There are some differences, though: When Tcl exits, the control returns to the ECLiPSe top-level loop.   This predicate can be used e.g. for rapid prototyping of Tcl-Prolog interface commands.

 

tk(+Options)
The basic predicate that initialises a Tcl interpreter and a Tk main window (if requested) and makes the use of all interface predicates possible. Options is a list of options, similar to the command-line options for wish:  

 

tk_demo
Starts the native Tk demonstration program.

 

tk_file(+File, +Options)
A synonym for tk([file(File)|Options]). Tk with options Options is started, the File is source'd and all Tk events are processed until the main window is manually destroyed or Tk exits.

 

tk_debug
When called in ECLiPSe trace or debug mode, this predicate causes all pending Tk events to be processed before each debugger line is printed. It is usually called from the top-level loop together   with the goal being debugged, e.g.
tk_debug, start_interface
This predicate changes the ECLiPSe event handler for the event 252 to call the Tk update command before printing the debugger line.   Note that it must be called together with the debugged predicate, because the handler for the event 252 is reset before each new top-level query.

 

tk_do_one_event(+Mask)
Process one Tk event corresponding to the mask Mask. If there is no such event, it fails. If a prolog_event   was invoked inside the Tk event, the ECLiPSe event 333 will be raised, its second argument   being the list of the prolog_event arguments. Mask is a bit-significant integer as specified in tk_do_one_event/2  .

 

tk_do_one_event(+Mask, -Event)
The predicate processes one Tk event corresponding to the mask Mask. If there is no such event, it fails. If a prolog_event   was invoked inside the Tk event, Event will be unified with a list of the prolog_event arguments. If no Prolog graphics event occurred, Event will be unified with []. The Mask is a bit-significant integer with the following meaning: The value 0 is equivalent to 16+8+4+2. If the bit value 1 is set, the predicate will block and wait until a specified event occurs or until Tk exits.

 

tk_file_handler(+Stream, +Status)
  Set up or delete a Tk file handler for the ECLiPSe stream Stream. If Status is on, the file handler is installed, if it is off, it is deleted. When this Tk file handler is installed and input data becomes available on the stream, a Tk and Prolog graphics event is raised, so that tk_do_one_event/2   succeeds and tk_get_event/1   and tk_next_event/1   succeed with the event ["file", StreamNo], where StreamNo is the number of the stream Stream, i.e. get_stream(Stream, StreamNo) holds.

 

tk_get_event(-Event)
Serve all already pending Tk events but do not wait for new ones. If there is also a pending Prolog graphics event, it is returned in the Event argument. If there is no pending Prolog graphics event, the predicate eventually fails.

 

tk_get_event(+Mask, -Event)
This predicate first serves all pending Tk events corresponding the the mask Mask. Mask is a bit-significant integer as specified in tk_do_one_event/2  . If there is also a pending Prolog graphics event, it is returned in the Event argument. If there is no pending Prolog graphics event, the predicate fails after serving all matching Tk events.

 

tk_load(+Files)
Load external objects files together with Tcl/Tk. Files is a string containing all object files, libraries and linker parameters which are necessary to dynamically load a Tcl/Tk extension.

 

tk_next_event(-Event)
Serve all pending Tk events. If there is also a pending Prolog graphics event, it is returned immediately in the Event argument. Otherwise, the predicate waits until a Prolog graphics event occurs. If Tk exits during this time, Event is unified with ["exit"] and the predicate returns.  

 

tk_next_event(+Mask, -Event)
This predicate first serves all pending Tk events corresponding the the mask Mask. Mask is a bit-significant integer as specified in tk_do_one_event/2  . If there is also a pending Prolog graphics event, it is returned immediately in the Event argument. Otherwise, the predicate waits until a matching Prolog graphics event occurs. If Tk exits during this time, Event is unified with ["exit"] and the predicate returns.  

 

tk_num_main_windows(-Num)
Num is unified with the number of currently existing main windows.   If it is zero, it means that Tk has exited or that its toplevel window   has been manually destroyed.

 

tk_wait_input(+Stream)
  This predicate waits until there is input data available in the Prolog stream Stream, or the stream is closed, or Tk exits. While waiting, all Tk events are served. If a Prolog graphics event occurs, the ECLiPSe event 333 is raised.   If no Tk windows are open, the predicate returns immediately.

 

wish
A wish-like interpreter loop will be started.   If Tk is not running, it will be started. The loop behaves very much like the Tk wish program, it prints the prompt, reads user input and executes it as a Tcl command. There are some differences: When Tk exits, the control returns to the ECLiPSe top-level loop.   This predicate can be used e.g. for rapid prototyping of Tk-Prolog interface commands.



next up previous index
Next: Xlib Predicates Up: ProTcXl 2.1 User Previous: Other Information Sources



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