Welcome to the ever growing family of PDT users! The chapters below will help you setting up and using the Prolog Development Tool.
If you haven't done it already, you have to set up the PDT first. See Installation for details.
The PDT offers a Prolog perspective, which provides a useful arrangement of all important views offered by the PDT.
To open the Prolog perspective select it in the “Open Perspective” window (see screenshot), which you can get via the menu “Window” → “Open Perspective” → “Other…”.
The Prolog Perspective contains the following views:
- Project Explorer: Handling projects, files, entry points, etc.
- Prolog Editor: Editor for Prolog files (including: syntax highlighting, warning/error markers, breakpoints, code completion …)
- Outline: Outline for the file which is currently open in the editor.
- Prolog Console: Handling of processes and queries.
- PDT Context View: graphical representation of the file in the editor.
This is, how it looks:
After opening the Prolog Perspective, create or select a Prolog process in the Prolog Console View .
- Select: Click on the first icon in the Prolog Console's toolbar (“Process Switcher”) to see which Prolog processes are currently running. Select one of them.
- Create: Click on the second icon in the toolbar (“Create Process”) and enter a name (any string).
The name of the selected or newly created process will appear in the top left corner of the Prolog Console. If the process was newly created, you will see the welcome message displayed below.
Now you can use the Prolog Console to run your Prolog queries. For a test that the installation is working nicely type:
Don't forget the closing period (”.”) and pressing <enter> or <return>. If your console looks like on the screenshot below and the shown version number is 51134 or higher everything is fine:
- Right click in the Package Explorer
- Select New → Example… → PDT Example Projects
- Choose “PDT Example Project” and click Finish
If you want to create an empty project, select New → Project… → General → Project. Adding a Prolog file can be done by New → File… (with the extension .pl).
Files are always consulted into the “current Prolog process”, that is the Prolog process whose name is displayed in the top left corner of the Prolog Console. If nothing is displayed there, select or create a prolog process first.
To consult a Prolog file either:
- right click on the file in the Package Explorer and select “Prolog Development Tools - (Re)consult” or
- open an editor for the file and when the editor has focus press <F9>
- edit your file and save it – saving will automatically (re)consult it.1)
In either case, you will see a message about successful consult action (or error messages) in the Prolog Console.
If the consult was sucessfully, the file's icon in the Explorer will turn green. Every folder that contains at least one consulted file is also indicated by a green background.
Consulting the load.pl from the PDT Tutorial Project will automatically consult all the other files.
|Consult action in Explorer||Explorer after consulting|
Now you can start a query:
- Type “likes(X,Y).” after the prompt of the Prolog Console. Don't forget the period.
- Press <return>
- The first result (X = jack, Y = kate) is displayed and the background color of the Prolog Console gets light yellow, indicating that that there are more results and the console is waiting for the user to decide whether to display them or stop.
- To terminate the query, you can type <return> or “a” (for “abort”).
- To see the next result, hit the space bar (” ”) or type a semicolon (”;”).
- In the latter case, the Prolog Console shows the second result (X = sawyer, Y = kate), and so on.
- If there are no more results (orif you aborted the query), the background color turns white again and you can enter another query.
Now you know the basics about how to use the PDT. You can continue with the Prolog Editor chapter and find out about it's features.