info-gnuprologjava
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Info-gnuprologjava] few questions about your package


From: Daniel Thomas
Subject: Re: [Info-gnuprologjava] few questions about your package
Date: Wed, 21 Dec 2011 13:44:19 +0000

How exactly is it not working properly?

I won't compile as 'label.getText()"."' is invalid and you don't need to
add in "." like that which might be the problem you are getting when you
create the goalTerm as you put a . in when you don't need to. The the
CompoundTerm is not being correctly constructed as the first argument is
the functor and so should just be "read_words" without any brackets or
arguments - that is what args is for.

I hope that helps,

Daniel


On Tue, 2011-12-20 at 21:35 +0300, Noor Ahmed wrote:
> 
> Hello,
> 
> I have a few questions about your package. The setup instructions are
> not clear. I am using WIN-Prolog, and want to connect it to an
> interface created in Java.
> In WIN-Prolog I have to write "read_words" to run the program, which
> takes a line of string -that comes from the interface- for processing.
> 
> So this is the code I wrote, I'm very sure it's wrong because it's not
> working properly:
> "
> 
>     Environment en = new Environment();
> 
> en.ensureLoaded(AtomTerm.get("/Users/NetBeansProjects/e-Q/src/pkginterface/code.pl"));
>     
>     Interpreter intr;
>     AtomTerm ans = null;
>     
>     intr = en.createInterpreter();
>     
>         
>         VariableTerm str = new VariableTerm(label.getText()".");
>     
>       Term[] args = {str};
>      
>      CompoundTerm goalTerm = new CompoundTerm("read_words(A).", args);
>     
>      en.runInitialization(intr);
>         try {
>             intr.runOnce(goalTerm);
>         } catch (PrologException ex) {
> 
> Logger.getLogger(checkBalance.class.getName()).log(Level.SEVERE, null,
> ex);
>         }
>         
>        ans = (AtomTerm) goalTerm.dereference();
>        
>         String check = ans.toString();
> "
>                  
> Please can you reply soon. Thank you.
> 
> 
> Regards.
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]