How to... |
| Home | Presentation | JIP Console | Built-In | API | Intelligent Applets | Contacts |
How to run JIPConsole as an application:Fisrt of alla you must have installed on your machine the Java™ Development Kit JDK 1.1.x or later or the Java™ Runtime Environment JRE 1.1.x or later. You can download them from: http://www.javasoft.com/products/jdk/1.1/ http://www.javasoft.com/products/jdk/1.1/jre/index.html To run JIPConsole: - if you add JIPackage.zip package to the classpath environment variable you can use java JIP.JIPConsole - otherwise you would use java -classpath %CLASSPATH%;<JIPDir>/JIPPackage.zip JIP.JIPConsole How to run your prolog code as a "stand alone" application using JIProlog interpreterFisrt of alla you must have installed on your machine the Java™ Development Kit JDK1.1.x or later or the Java™ Runtime Environment JRE1.1.x or later. You can download them from: http://www.javasoft.com/products/jdk/1.1/ http://www.javasoft.com/products/jdk/1.1/jre/index.html Then, you must define in your prolog code the entry-point predicate main/0 (it will be called when the interpreter will start) as the example belows: main:- Finally you can run you prolog code by JIProlog interpreter: - if you add JIPackage.zip package to the classpath environment variable you can use java JIP.JIProlog <MyPrologFile> - otherwise you have to use java -classpath %CLASSPATH%;<JIPDir>/JIPPackage.zip JIP.JIProlog <MyPrologFile> How to trace your program by JIPConsole:1) Check the box "Trace" between the buttons
below. Press "Step" button to go to next step, press "Skip" to skip trace or "Abort" to stop the execution. How to write a custom Dialog:Suppose you have a dialog class MyDialog derived from java.awt.Dialog that you would use in JIP. You must create a new class following the skeleton shown below: public class MyDialog4JIP
extends MyDialog
implements JIPDialog An example is the message box shown by wmsgbox/1 predicate (wmsgbox(Message)):
class JIPMessageDialog
extends
MessageDialog implements
JIPDialog How to write a custom extension class:Suppose you have a Java™ class MyClass derived from any Java™ classes that you would use in JIP. You have to create a new class following the skeleton shown below: public class MyClass4JIP
extends AnyClass
implements JIPXCall An example is the implementation of a class that generate random numbers in the range [min, max]: public class RandomNumberGen extends Random implements JIPXCall{ int m_nMin, m_nMax; public void invoke(JIPTerm input) { if(input.isList()) { JIPList list = input.getList(); JIPNumber min = list.getHead().getNumber(); JIPNumber max = list.getTail().getHead().getNumber(); m_nMin = (int)min.getValue(); m_nMax = (int)max.getValue(); } else { throw new RuntimeException("The second parameter is bad"); } } public
JIPTerm getOutput() How to write an external database of clauses:An external database of
clauses is a database not stored in the
prolog memory but in an external device such as JDBC database, text database
and so on. The predicate extern/3 allow you to declare a predicate as an external predicate. To implement a database of clauses you must derive a class from the abstract class JIPClausesDatabase and implement a JIPClausesEnumeration to enumerate the facts in sequence. You must implement: /** Set attributes to pass to the database (i.e. login info, filename, etc.) public abstract void setAttributes(String strAttribs); /** Add a clause to the
database at the position specified /**
Append a clause to the database /**
Remove a clause to the database /**
Return an enumeration of clauses contained in the database Then you must implement the method: /** Get next clause in the enumeration of clauses As an example, the files TextClausesDatabase.java and TextClausesEnumeration.java implement a detabase of clauses stored in a text file. You can try it in JIP by typing: JIP:-extern(foo/3,
"JIP.TextClausesDatabase", "database.txt"). JIP:-foo(X,Y,Z). |
| Home | Presentation | JIP Console | Built-In | API | Intelligent Applets | Contacts |
Copyright © Ugo Chirico
This page hosted by Get your own Free Home Page