Re: Java: Knowledge-Base not via file

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Fri 16 Jan 2004 12:33:08 PM GMT
Message-ID: <4007DA04.3010108@icparc.ic.ac.uk>
Sebastian Weber wrote:

 > Hello,
 >
 > I'm building an Java-application using the Java-Interface of Eclipse.
 > I want to setup a knowledge-base not via file as it usually happens,
 > because I am going to create the base dynamically.
 >
 > In Eclipse (and other Prolog Systems) you can setup a knowledge base
 > like that, too:
 > Type "compile(user)." or "[user]." in console and enter the rules
 > (...). The input can be stopped with CTRL+D or through entering the
 > atom "end_of_file".
 > My problem: How is it possible, to do this, using the Java-Interface
 > of Eclipse?


"compile(user)." reads terms from stdin and gives them to the compiler.
This is only useful in a console-based development environment. When
your Eclipse is embedded into a Java application, you may not even
have a stdin stream.

The structure of a Java/Eclipse application should be such that you do
all your I/O in Java, and pass data between Java and Eclipse code via
the rpc method or via the To/FromEclipseQueue mechanism.

For example, you could read your rules in Java as a string (e.g. using
some GUI input window), and then use rpc to call the eclipse goal

     compile_string(<string containing your rules>)

Where you need to have defined compile_string/1 as follows:

     compile_string(String) :-
     open(string(String), read, Stream),
     compile_stream(Stream),
     close(Stream).


-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Fri Jan 16 12:36:17 2004

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:26 PM GMT GMT