Re: SWI-Prolog Query
Grzegorz JaĆkiewicz <[email protected]> Tue, 15 Apr 2014 19:00:34 +0200
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CABWt2Wndjs3ZXfLOdHSCeBrOhf+isQ-Jwwe-agz7bOJo1BSC-w@mail.gmail.com> |
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