Go to the first, previous, next, last section, table of contents.


Low level interface library to Tcl/Tk

Author(s): Montse Iglesias Urraca.

Version: 1.7#125 (2001/10/17, 13:42:47 CEST)

Version of last change: 1.7#124 (2001/9/2, 14:14:25 CEST)

The tcltk_low_level library defines the low level interface used by the tcltk library. Essentially it includes all the code related directly to the handling of sockets and processes. This library should normally not be used directly by user programs, which use tcltk instead. On the other hand in some cases it may be useful to undertand how this library works in order to understand possible problems in programs that use the tcltk library.

Usage and interface (tcltk_low_level)

Documentation on exports (tcltk_low_level)

PREDICATE: new_interp/1:

Usage: new_interp(-TclInterpreter)

PREDICATE: new_interp/2:

Usage: new_interp(-TclInterpreter,+Options)

PREDICATE: new_interp_file/2:

Usage: new_interp_file(+FileName,-TclInterpreter)

PREDICATE: tcltk/2:

Usage: tcltk(+Code,+TclInterpreter)

PREDICATE: tcltk_raw_code/2:

Usage: tcltk_raw_code(+String,+TclInterpreter)

PREDICATE: receive_result/2:

Usage: receive_result(-Result,+TclInterpreter)

PREDICATE: send_term/2:

Usage: send_term(+String,+TclInterpreter)

PREDICATE: receive_event/2:

Usage: receive_event(-Event,+TclInterpreter)

PREDICATE: receive_list/2:

Usage: receive_list(-List,+TclInterpreter)

PREDICATE: receive_confirm/2:

Usage: receive_confirm(-String,+TclInterpreter)

PREDICATE: delete/1:

Usage: delete(+TclInterpreter)

Documentation on internals (tcltk_low_level)

PREDICATE: core/1:

Usage: core(+String)

Other information (tcltk_low_level)

Two sockets are created to connect the TclInterpreter and the prolog process: the event_socket and the term_socket. There are two global variables: prolog_variables and terms. The value of any of the variables in the goal that is bound to a term will be stored in the array prolog_variables with the variable name as index. The string which contains the printed representation of prolog terms is Terms. These are the Tcl/Tk procedures which implement the interface (the code is inside the tcltk_low_level library):

prolog
Sends to term_socket the predicate tcl_result which contains the goal to execute. Returns the string executes and the goal.
prolog_event
Adds the new term to the terms queue.
prolog_delete_event
Deletes the first term of the terms queue.
prolog_list_events
Sends all the terms of the terms queue by the event_socket. The last element will be end_of_event_list.
prolog_cmd
Receives as an argument the tcltk code. Evaluates the code and returns through the term_socket the term tcl_error if there was a mistake in the code or the predicate tcl_result with the result of the command executed. If the argument is prolog with a goal to execute, before finishing, the predicate evaluated by prolog is received. In order to get the value of the variables, predicates are compared using the unify_term procedure. Returs 0 when the sript runs without errors, and 1 if there is an error.
prolog_one_event
Receives as an argument the term which is associated with one of the tk events. Sends through the event_socket the term and waits the unificated term by prolog. After that it calls the unify_term procedure to obtain the value of the prolog_variables.
prolog_thread_event
Receives as an argument the term which is associated with one of the tk events. Sends through the event_socket the term and waits for the term unified by prolog. After that the unify_term procedure is called to obtain the value of the prolog_variables. In this case the term_socket is non blocking.
convert_variables
Receives as an argument a string which contains symbols that can't be sent by the sockets. This procedure deletes them from the input string and returns the new string.
unify_term
Receives as argument a prolog term.


Go to the first, previous, next, last section, table of contents.