PART 1    Using the Environment

 

CHAPTER 1    Using the Visual Prolog Environment

 

This chapter describes the basic operation of the Visual Prolog system focusing on running the examples described in this book.

We assume, that you have experience using the Graphical User Interface system, the windowing system. This might be either Windows 3.x, Windows 95, Windows NT, Win-OS/2 or OS/2 PM. You should thus know about using menus, closing and resizing windows, loading a file in the File Open dialog etc. If you do not have this knowledge, you should not start off trying to create an application that runs under this environment. You must first learn to use the environment.

If you are a beginner to Prolog, you don¡¯t want to mix learning the Prolog language with the complexity of creating Windows applications with event handling and all the Windows options and possibilities. The code for the examples in this book are platform independent: They can run in DOS text mode, under UNIX, or with the adding of a little extra code for the User Interface handling, in a Windowing environment like MS Windows or OS/2 PM.

We do suggest, that you at an early stage try compiling some of the examples in the VPI subdirectory, and work your way through the Guided Tour in the Getting Started book. This gives you an impression what can be done with Visual Prolog - just so you know what you should be able to do, when you have learned to master Visual Prolog.

However, if you are going to seriously use the Visual Prolog system, you need to learn the basic concepts of Prolog properly. You will not be able to build a skyscraper without having a solid foundation. In Visual Prolog, the foundation is understanding the Prolog language and the VPI layer.

 

What Needs to be Installed for This Book ?

To Run and test the examples in this book you need during installation to:

Install the Visual Development Environment. You can choose the Win16 version or the Win32 version if you own the Professional version of

In the Dialog for choosing Documentation; install "Answers to exercises" and "Examples".

Starting the Visual Prolog Environment

The installation program will install a program group with an Icon which are normally used to start the Visual Prolog Environment. However, there are many ways to start an application in the GUI World, if you prefer another method, you can just start the VIP.EXE down in the BIN\WIN\16 or the BIN\WIN\32 directories under the main VIP directory.

If Visual Prolog had an open project (a .VPR file) last time it was closed on your computer, it will automatically reopen this project next time it starts. For the examples in this manual, you do not need to have an open project.

Opening an Editor Window

To create a new edit window, you can use the menu command File | New. This will bring up a new editor window with the title "NONAME".

The editor is a fairly standard text editor. It is documented in the VDE manual, but you should be able to use cursor keys and the mouse as you are used to in other editors. It supports cut, copy and Paste and Undo / Redo, which you can all be activated from the Edit menu. Also the Edit menu shows the accelerator keys associated for these actions.

Running and Testing a Program

To check, that your system is set up properly, you should try to type in the following text in the window:

    GOAL write("Hello world"),nl.

This is what is called a GOAL in the Prolog terminology, and this is enough to be a program that can be executed. To execute the GOAL, you should activate the menu item Project | Test Goal, or just press the accelerator key Ctrl+G. If your system is installed properly, your screen will look like the following:

 

The result of the execution will come up in a separate window, which you must close before you can test another GOAL.

(The Visual Prolog system treats the GOAL as a program which it compiles, links and generates a Windows executable from. It uses the EASYWIN strategy, which is described in the VDE manual.).

Loading Examples From Disk

The examples in this manual are provided on the disk. You can find them in the subdirectory: DOC\EXAMPLES. Also there are some answers to exercises in the subdirectory DOC\ANSWERS.

They're named after the chapter they appear in: chCCeNN.pro, where CC will be 02, 03, 04, etc. according to chapter, and NN is the example number within that chapter (01, 02, 03, etc.).

You should now try to open one of these example, and test one. You should just use the File | Open command to open the file, and the press Ctrl+G to test the GOAL.

Handling Errors

If you, like all programmers do, happen to make some errors in your program, the Visual Prolog system will display an error window, which contains a list of errors. You can double click on one of these errors to come to the position of the error in the source text.