Re: SWI-Prolog Query

Pavan Kumar <[email protected]> Tue, 15 Apr 2014 13:46:24 -0500
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAFVqwvhJqm_ie-mY7287dnSKJRSk3MVZ07_2XLyxzAXYG1pyaA@mail.gmail.com>
I see a http://www.swi-prolog.org/packages/jpl/java_api/ Interface for
Java. Is this the recommended and better way to call SWI-Prolog from Java
Programs?

I just have a Query generated by java Program which I need to pass on to
SWI-Prolog, and make swi-Prolog to write the Output to a file and then
another Java function uses that file for further processing.

Hope I am clear now. Kindly comment.

Thanks,
Pavan.


On Tue, Apr 15, 2014 at 12:00 PM, Grzegorz Jaƛkiewicz <
[email protected]> wrote:

> As far as i understand you are running Prolog interpreter as OS command,
> eg. "Runtime.getRuntime().exec("swipl");"
> Am i right?
>
> if so, you could use -s flag in the call to specify the source file to be
> loaded by interpreter and -t for toplevel goal, eg.
> Runtime.getRuntime().exec("swipl -s blah.pl -t somegoal");
>
> to output to file use "tell" predicate in goal specified by -t
> eg. -t "tell('out.txt'), my_predicate(X), write(X), told"
>
> "my_predicate" is a predicate you want to call.
>
> HTH
>
>
>
>
>
> 2014-04-15 16:49 GMT+02:00 Pavan Kumar <[email protected]>:
>
>> I have a Java Program that generates a SWI-Prolog Query and writes to a
>> file, I need to Invoke SWI-Prolog from my Java Program and SWI-Prolog
>> should take the file having the Query as Input and write the Output to
>> another file.
>> So, I found Open(/4) in SWI-Prolog but didn't understand it, its usage and
>> how to make SWI-Prolog execute the Command in that file and also specify
>> the Target Output file that SWI-Prolog should write to.
>>
>> Also Is it possible to call SWI-Prolog from my Java Program and make it
>> execute the Query in file? if yes, can anyone let me know how to do it?
>> Also, There can be one or more commands in the Input file for SWI-Prolog
>> It
>> should execute the commands in that file and write output to a Target file
>> mentioned.
>> -------------- next part --------------
>> HTML attachment scrubbed and removed
>> _______________________________________________
>> SWI-Prolog mailing list
>> [email protected]
>> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>>
>
>
-------------- next part --------------
HTML attachment scrubbed and removed
_______________________________________________
SWI-Prolog mailing list
[email protected]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog