Author(s): Montse Iglesias Urraca, http://www.clip.dia.fi.upm.es/
, The CLIP Group, Facultad de Informática, Universidad Politécnica de Madrid.
Version: 1.7#93 (2001/4/24, 19:2:53 CEST)
Version of last change: 1.5#16 (1999/12/14, 17:12:49 MET)
The
tcltk
library package is a bidirectional interface to the Tcl (pronounced Tickle) language and Tk toolkit. Tcl is an interpreter scripting language with many extensions packages, in particular the graphical interface toolkit Tk. The proposed interaction between both languages is realized as an interface between two process, a Tcl/Tk process and a Prolog process. This approach allows programmers to use both Tcl/Tk and Prolog.
The interface is made up of two parts: a Prolog part and a Tcl/Tk part. The Prolog part receives requests from a Prolog program and sends them to the Tcl/Tk part. The Tcl/Tk part receives from the socket and performs the actions included in the requests.
The Prolog side receives the actions to do in the Tcl/Tk side from the user program, and sends them to the Tcl/Tk side through the socket connection. When the action is done in the Tcl/Tk side, the result is retrieved to the user program, or the action fails if any problem sucess.
The Tcl/Tk side waits for requests from the Prolog side, executes the Tcl/Tk code sended from the Prolog side, handle the events and exceptions raised in the Tcl/Tk side.
tcltk
):- use_module(library(tcltk)).
tcltk
)To use Tcl, you must create a Tcl interpreter object and send commands to it.
Usage: tclInterpreter(I)
I
is a reference to a Tcl interpreter.
A Tcl command is specified as follows:
Command --> Atom { other than [] } | Number | chars(PrologString) | write(Term) | format(Fmt,Args) | dq(Command) | br(Command) | sqb(Command) | min(Command) | ListOfCommands ListOfCommands --> [] |[Command|ListOfCommands]
where:
Usage: tclCommand(C)
C
is a Tcl command.
Usage: tcl_new(-TclInterpreter)
TclInterpreter
.
-TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tcl_eval(+TclInterpreter,+Command,-Result)
Command
in the Tcl interpreter in variable TclInterpreter
. The result will be stored as a string in Result
. If there is an error in the Command an exception is raised. The error messages will be Tcl Exception: if the error is in the syntax of the tcltk code or Prolog Exception: , if the error is in the prolog term.
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
+Command
is a Tcl command.
(tcltk:tclCommand/1
)
-Result
is a string (a list of character codes).
(basic_props:string/1
)
Usage: tcl_delete(+TclInterpreter)
TclInterpreter
, it deletes the interpreter from the system.
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tcl_event(+TclInterpreter,+Command,-Events)
Command
in Tcl interpreter handle provided in TclInterpreter
. Events
is a list of terms stored from Tcl by the prolog_event. Blocks until there is something on the event queue
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
+Command
is a Tcl command.
(tcltk:tclCommand/1
)
-Events
is a list.
(basic_props:list/1
)
Usage: tk_event_loop(+TclInterpreter)
execute(Goal)
, the predicate silently exists. If the execution of Goal
raises a Prolog error, the interpreter is deleted and an error message is given.
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tk_loop(+TclInterpreter)
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tk_new(+Options,-TclInterpreter)
Options
is a list of optional elements according to :
ApplicationName
. It is also used for communicating between Tcl/Tk applications via Tcl send command. Default name is an empty string.
+Options
is a list.
(basic_props:list/1
)
-TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
Usage: tk_next_event(+TclInterpreter,-Event)
TclInterpreter
. Event
is the term correspondig to the head of a queue of events stored from Tcl with the prolog_event command.
+TclInterpreter
is a reference to a Tcl interpreter.
(tcltk:tclInterpreter/1
)
-Event
is a string (a list of character codes).
(basic_props:string/1
)
Go to the first, previous, next, last section, table of contents.