Samples
The Amzi! samples are stored in the 'samples' subdirectory. The 'samples' subdirectory
has further subdirectories organized primarily by programming environment. The
sample names in this document reflect that directory structure. For example,
the sample C++ Hello console is in the directory amzi/samples/cpp/hello/console.
The samples in most of the directories are Logic Server API samples, with some
Prolog code and some environment-specific code. The environment-specific code
might be in a language, such as Delphi or C++, or use some other programming
interface, such as ODBC or CGI.
The Prolog subdirectory has samples that are pure Prolog.
In many cases a sample will be repeated in different environments. For
example, there is a pure Prolog version of the Rubik's cube program and
one that runs under a multi-threaded C++ front-end. The Hello Prolog program
is provided for most host language environments.
Many of the samples include a doc.html file with notes on the architecture
of the sample and how to build/deploy it. Most samples include some sort of
make file so they can be rebuilt easily. Makefiles ending in .win are for Windows,
.sol for Solaris, .lnx for Linux, etc. In general files that are Windows-only
(such as Windows IDE project files) all start with a 'w'. Most of the make files
require the environment variable AMZI_DIR to be set to your top-level amzi directory.
All samples include full source.
If you encounter any difficulties building or executing any of the samples,
send e-mail to support@amzi.com.
Contents
Topics
C
C++
Delphi
Expert Systems
Extended Predicates
Genealogy
Graphical Layout
GUI Applications
Hello Prolog
Java
Multiple Engines
Natural Language
ODBC
Pets
Prolog
Rubik's Cube
Sockets
Unicode
Visual Basic
Samples by Topic
C
The C samples illustrate the use of the native Logic Server API (LSAPI)
calls and error handling using return codes.
The C samples are implemented using Microsoft Visual C/C++ 5.0, but
because the Logic Server is a DLL, it can be linked to from any C environment
that can link with a Windows DLL.
The samples include an .exe file which can be run directly. They also
include a VC++ 5.0 .MAK file which can be used to rebuild the project.
Contents Topics
C++
The C++ examples illustrate the technique of deriving application specific
classes from the Logic Server class, as well as error handling using C++
catch/throw and Logic Server exceptions.
The C++ samples are implemented using Microsoft Visual C/C++ 5.0, but
because the Logic Server is a DLL, it can be linked to from any C++ environment
that can link with a Windows DLL.
They include a .exe file which can be run directly as well as a VC++
5.0 .MAK file which can be used to rebuild the project.
Contents Topics
Console Applications
By linking with AMZI.LIB/DLL, you can create console (UNIX terminal or DOS Box)
applications that support normal Prolog reads and writes to the console.
The console samples provide uncluttered code that illustrate the interaction
between the Logic Server and the host language.
It is usually best to run the console applications from the console,
otherwise the console window might appear and disappear before you can
see the results.
Contents Topics
Delphi
The Delphi samples were implemented using Delphi 3.0 and illustrate the
use of the Delphi Logic Server component. They include a .exe file so you
can run them directly and a Delphi project file so you can rebuild the
project.
Contents Topics
Extended Predicates
-
C++ Pets_Callback - Pets with callback extended predicates.
-
Delphi DelGUI - Simple test of Delphi GUI
library implemented with extended predicates.
-
Java Pets_Callback - The simple Pets expert
system using extended predicates written in Java.
-
VB ExtPred - A simple example of using extended
predicates for Prolog to call VB procedures.
Contents Topics
Expert Systems
These samples illustrate the use of Prolog for expert system applications
that dispense advice.
Contents Topics
Genealogy
A classic application of Prolog is the definition of family relationships
based on data about parents and children. This application is presented
in various formats in Amzi! samples.
Contents Topics
Graphical Layout
Prolog can be used to reason over spatial relationships as well as anything
else. These samples show the use of Prolog reasoning for graphical layout.
Contents Topics
GUI Applications
One of the motivations behind the Logic Server architecture was the desire
to allow various GUI tools to be used to develop user interfaces for Prolog
applications. These samples illustrate GUIs and the Logic Server.
Contents Topics
Hello Prolog
The Hello Prolog program is a very simple Prolog program designed to be
used as a first test case for calling Prolog from various environments.
Contents Topics
Java
To use the Java samples you must have installed Sun's Java Development
Kit 1.1 and installed the Amzi! Java class. See the Java
Class for details.
Contents Topics
Multiple Engines
Starting with the 4.0 release, Amzi! supports the running of multiple simultaneous
Logic Servers. These samples show host language applications using multiple
Logic Servers.
Contents Topics
Natural Language
Prolog is an excellent tool for parsing natural language. (It was originally
designed with this type of application in mind.)
Contents Topics
ODBC
The ODBC Logic Server Extension, LS4ODCBC.LSX, allows Prolog programs to
access data directly from any ODBC database. These samples illustrate that.
To use the samples, you must have ODBC 2.0 installed and the appropriate
drivers for the database.
Contents Topics
Pets
The Pets sample is a trivial expert system that can be used as a starting
point. It is implemented in various environments.
Contents Topics
Prolog
The pure Prolog samples are designed to be run from the Windows IDE or
the command line.
Contents Topics
Rubik's Cube
The Prolog code to solve Rubik's cube can be run in various environments
and with various interfaces.
Contents Topics
Sockets
The Logic Server LSX implementing sockets support can be used to implement
client/server connections directly from Prolog. For details on Amzi! Sockets
support see Sockets LSX.
Contents Topics
Unicode
Internally, Amzi! uses Unicode strings. They are directly accessible from
environments that support Unicode, such as Windows NT. These applications
highlight the use of Unicode and Prolog. (Multibyte to Unicode string conversion
functions enable multibyte applications to run under other environments,
such as Windows 95).
Contents Topics
Visual Basic
The Visual Basic samples are implemented using VB 5.0.
Contents Topics
Samples by Name
C Hello
The Hello Prolog example implemented a C console application.
Contents Topics
C Pets
The trivial Pets expert system with two Prolog engines working at identifying
different pets. Should be run from the console.
Contents Topics
C++ Hello Borland
The Hello Prolog example implemented as a C++ class using Borland C++.
Contents Topics
C++ Hello
Borland C++ Builder
The Hello Prolog example implemented as a C++ class and GUI using Borland's
C++ Builder
Contents Topics
C++ Hello Console
The Hello Prolog example implemented as a C++ class running as a console
application. Should be run from the console.
Contents Topics
C++ Hello Win32_MFC
The Hello Prolog example implemented as a C++ class running in a simple
MFC dialog application.
Contents Topics
C++ Pets
The trivial Pets expert system with two Prolog Logic Servers working at
identifying different pets. Should be run from the console.
Contents Topics
C++ Pets_Callback
A slightly more complex version of Pets in which the Prolog program has
a prompt/2 predicate used to get information from the user. In the example,
it is used to ask the user for the sound the pet makes.
prompt/2 is implemented as an extended predicate in the C++ class derived
from CLogicServer, illustrating the technique of having extended predicates
associated with instances of classes derived from the Logic Server.
This is a trivial console example, where there is no real point in having
multiple instances of the prompt/2 predicate, but the technique is important
for GUI applications where, for example, different instances of the Logic
Server might be associated with different windows on the screen.
Contents Topics
C++ Win32_Rubik_Multi
The Win32_Rubik_Multi (MultiThreaded) sample is an MDI MFC application. Each child
window has an unfolded view of a Rubik's cube and a 'Solve' button. When
the button is pressed, the cube is randomly scrambled and then solved.
The FILE/NEW menu item causes new child windows to be created, and each
one is associated with a new Logic Server, running in a separate thread.
When you click the 'Solve' button in multiple windows, each one shows
a cube being solved at the same (or as close to same as NT multi-threading
allows) time.
This demo was derived from the Microsoft multi-threaded 'Bounce' sample,
with solving Rubik's cube replacing the bouncing balls.
Contents Topics
Delphi DelGUI
DelGUI is a collection of extended GUI predicates implemented in Delphi
for use with Prolog applications embedded in Delphi. The test sample here
just puts up a button and a window to verify that the Amzi! Delphi component
and DelGUI library are working.
Contents Topics
Delphi Eq
The Eq Delphi sample demonstrates Prologs ability to do graphical layout
in conjunction with Delphi drawing functions. The particular example takes
equations written programmatically and renders them as they might appear
in a mathematics textbook.
Contents Topics
Delphi Hello
Hello Prolog from Delphi, as a simple dialog application.
Contents Topics
Delphi ProXS
The ProXS Delphi sample demonstrates how to put a GUI front-end onto a
sophisticated expert system written in Prolog. This sample uses bird identification
as its knowledgebase, but it the Prolog portion of the sample is a general
goal-driven engine that can be readily adapted to other applications.
Contents Topics
Delphi SSched
An expert system that does round-robin scheduling of teams (sports scheduling).
It uses a graphical Delphi front-end to build and display the schedule,
and a simplified version of the scheduling program used for college basketball.
Contents Topics
Delphi Test
An application that illustrates a number of Logic Server features in a
simple test program. Features include asserts, queries, extended predicates,
and message boxes.
Contents Topics
Internet CGI Hello
The simplist Amzi! CGI script.
Contents Topics
Internet CGI Infoform
An simple example of using the Amzi! CGI script capabilities with an HTML information
request form.
Contents Topics
Internet Sockets
A5SOCK.LSX implements extended predicates that connect Prolog to Windows
Sockets. The sample programs show how to implement a finger client, and
a simple client/server application using just Prolog running from the IDE.
For details on A5SOCK.LSX see Sockets LSX.
Contents Topics
Java Hello
Hello Prolog from Java, used to see if you've got all of the Java stuff
installed correctly. See Java Class for details.
Contents Topics
Java Pets_Callback
The Pets expert system, illustrating multiple engines and extended predicates
in a console Java application. See Java Class
for details.
Contents Topics
Java Ship
A prototype expert system for recommending package shipping options based
on package weight, destination and priority. It uses a GUI developed in
Java. See Java Class for details.
Contents Topics
LSX Xarray
A simple example implementing a Logic Server Extension (.lsx) DLL with extended
predicate definitions. In this case the extended predicates provide simple
array capabilities to Prolog.
Contents Topics
ODBC DBGene
The ODBC Logic Server Extension, LS4ODBC.LSX, implements extended predicates
that connect Prolog to ODBC data sources. The DBGene sample uses an Access
database to store data about people, Prolog to represent the rules for
different family relationships, and Visual C++ for a GUI front-end.
The program illustrates C++ calling Prolog with a query, Prolog resolving
the query using both Prolog rules and ODBC queries, and returning values
displayed in Visual C++ list boxes.
Contents Topics
ODBC Events
Illustrates the use of date and time fields from Prolog with ODBC.
Contents Topics
ODBC VBGene
An example of a VB program calling a Prolog program of family relationships
that calls an ODBC database for family data.
Contents Topics
Prolog Babel
Babel is a simple machine translation demo that recognizes the input language
of a sentence and translates it into all of the other supported languages.
It uses Unicode to represent the characters in the languages.
Contents Topics
Prolog Ducks
The Ducks adventure game example used in the Prolog programmer's guide
short tutorial.
Contents Topics
Prolog Logic
This is a version of the Clocksin & Mellish program that translates
formal logic into Prolog clauses. The only difference is the program takes
advantage of Amzi! Unicode support, and uses the real logic symbols for
'not', 'and', 'exists', etc.
Contents Topics
Prolog Misc
A collection of Prolog programs that haven't been cataloged. Look at the
text file in this sample directory for descriptions of the sample programs.
Includes Prolog-only versions of ProXS, Ship and SSched, a mailing list
translator, income tax program and the Warren Planner.
Contents Topics
Prolog Rubik
The Rubik's Cube solver runs by itself in the IDE, or from the console,
using a text based representation of the cube as its solved. Simple choose
build/run and select rubik.xpl to see it run.
Contents Topics
VB ExtPred
This example shows how to create Prolog predicates that are implemented
by Visual Basic procedures using VB 5.0 or later.
Contents Topics
VB Hello
Hello Prolog from Visual Basic.
Contents Topics
VB Test
A VB program that exercises a number of features of the Logic Server API.
Contents Topics
VB WGene
The Genealogy application implemented with a VB front-end. The people data
and the rules are both stored in Prolog.
Contents Topics
Copyright ©1987-2000 Amzi! inc. All Rights Reserved.