Re: Problem with obtaining an result in java

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Fri 01 Apr 2005 04:15:45 PM GMT
Message-ID: <424D73B1.4080507@icparc.ic.ac.uk>
Kronawitter Katharina wrote:
> Hi,
> 
> can you help me?
> 
> I've got a constraint logic program without variables in the head
> (because of the limit of 255 variables) and I don't know how to get a
> solution for the variables in the program into my Java-Programm.
> 
> With variables in the head, I was able to get the results for the
> variables like that:
> 
> String call = "h(F_l_BWB_t00_t0002, F_s_BWB_t00_t0002,
> F_m_BWB_t00_t0002).";
> CompoundTerm result = eclipse.rpc(call);
> for (int i = 1; i <= result.arity(); i++) {
> 
>        Object o = result.arg(i);
> }
> 
> As that doesn't work anymore, I tried to use write-statements in the
> program, but then, the results are only in the standard-output and I
> can't access the values.


There are basically two solutions:

1. Let your toplevel predicate take a single (variable) argument, which
    your Eclipse code then instantiates to a list (or structure) of results.
    After returning from Eclipse to Java, the Java code can traverse or
    decompose this list (or structure).

2. Learn how to use queues to do the Java/Eclipse communication. There
    are very simple code examples QueueExample1.java and QueueExample2.java
    in the examples/JavaInterface directory.


-- 
  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 Apr 01 17:23:38 2005

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