Http://blog.csdn.net/lawme/archive/2008/10/17/3089770.aspx
6. briefly explain the statements related to GTK-Server
This is a basic knowledge of PROLOG syntax and usage. refer to the following tutorial.
Http://www.csupomona.edu /~ Jrfisher/www/prolog_tutorial/contents.html
For the internal predicates of GNU Prolog, see
Http://www.gprolog.org/manual/gprolog.html
(1) automatically executed statements
After the program tictactoe. pl is started, this statement is executed unconditionally. It does not have a first-sentence identifier, or can be called a "headless clause ".
There are two sentences in tictactoe. Pl:
:-Dynamic (X/1, O/1, signals/5, labels/1 ).
:-Initialization (START ).
The first sentence defines four "dynamic predicates": X (_), O (_), signals (_, _), label (_).
"Dynamic predicates" can be viewed as "global variables with multiple values that can be added, deleted, and modified" in the sense of purpose ".
"Dynamic predicates" are called "internal databases" in Visual Prolog ".
Second, call the predicate start to run the program.
(2) Implement GUI statements
(1) Call the GNU Prolog preexec to establish a connection with the GTK-server.
Exec ('gtk-server stdin post =. ', pout, pin ,_,_)
'Gtk-server stdin post =. 'Is a DOS console command that enables both parties to establish a connection in stdin mode. This connection establishes a pipe bidirectional channel;
Pout, pin is the corresponding I/O Stream (Stream) generated by the "constraint", which can be understood as the "Return Value" after the statement is executed ".
(2) predicate GUI and GTK
After the GUI determines what the GTK-server wants to do, GTK notifies the GTK-server to execute it through the I/O channel.
GTK-server provides the GUI service for the script program. The script program calls the Service Statement, which can be a simple string and parsed by the server. For example,
GTK (pin, pout, ['gtk_init null null'], _)
In 'gtk_init null null', it will be analyzed on the server as gtk_init (null, null ,)
Call the gtk_init function of GTK.
(3) The predicate loop for Processing Event
A loop predicate has multiple clauses. Basically, a partial clause processes an event and implements the while loop function.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/lawme/archive/2008/10/17/3089770.aspx