Taste GNU Prolog (3)

Source: Internet
Author: User
Tags gtk null null

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.