GUI for a Turbo Prolog application

1.4k views Asked by At

I have an university assignment where my goal is to create a GUI for an expert system created in Turbo Prolog. Is there any common way to do this? Or is there a way that, for example, a Java application can call the Prolog application and import its results? Or should I port my application to Visual Prolog? Thanks in advance.

2

There are 2 answers

0
hardmath On

The "native" approach for a GUI with Turbo Prolog was the DOS-based Borland Graphics Interface (BGI). This library is not per se compatible with MS Windows, but you don't indicate what operating system you are targeting with this application.

If you are targeting Windows and want to use BGI graphics, then it's possible you'll find this Windows-port of BGI usable.

If you've never used BGI calls before in Turbo Prolog, then it is perhaps attractive to upgrade to Visual Prolog, which PDC maintains with current releases of MS Windows. The building blocks for a user-interface are very much at hand in the Visual Prolog IDE.

Added: I once built a graphical prototype of a warehouse/logistic system, displaying where specific items are located on a warehouse floor, using Turbo Prolog and BGI calls. So this could be done, I think, for your "university assignment". Less work than cooking up a way for Java to call Turbo Prolog, although there are several Prolog implementations that either interface with or are written in Java. GNU Prolog for Java is free and open source, for example.

Converting from Turbo Prolog to ISO Prolog is not all that hard, unless you are using an external database or other feature intrinsic to Turbo Prolog. Basically you just need to strip out the domain and predicate declarations peculiar to Turbo Prolog, and you'll likely have something that can be tested and run under a wide range of ISO Prolog implementations. If your expert system does use an external database, you'll find it attractive to convert to an internal database (fact clauses) that gets dynamically populated using consult/1 and/or assertz/1.

0
Thanos Tintinidis On

Well, there is XPCE which is quite nice but I am not 100% sure whether you will be able to use it in Turbo Prolog or you would have to make some modifications; however, since porting is not out of question I guess you could use it.

This is a very useful (imho) FAQ/Guide about XPCE

Some other options from swi-prolog's page about graphics:

Direct access to graphical API Traditionally, people in the Prolog community have written Prolog wrappers around the native (C) API of their system. Xwip is an important example of this class of GUI approach for Prolog. Problem is that most of these API's are fairly low-level and a lot of work is required to get the data types of the API properly and naturally represented in Prolog. External GUI language A better and more popular approach is to use an external language designed for GUI development. Popular candidates are Tk/Tcl, JPL/Java, Visual Basic and Delphi. Prolog is connected to these systems using pipes, embedding or other suitable communication mechanisms. Using XPCE star.gif XPCE has been developed for GUI development in Prolog from the start. XPCE has a dynamically typed object-oriented kernel. Methods can be defined in any language. XPCE predefines a large number of classes, aiming at data-representation as well as graphics. The graphical library allows for abstract description of interface components and is portable to Win32 and Unix/X11.

Using XPCE, interactive Prolog applications can be written completely in Prolog. XPCE can be used for (space-)efficient storage of objects and object-oriented structuring of your application. As of XPCE-5, native Prolog-data can be passed and stored with XPCE/Prolog defined classes.