Re: [JPL][DCG] Load .pl file from internet
Paul Singleton <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Organization | Jambusters Ltd |
| Message-ID | <[email protected]> |
On 05/12/2013 15:57, Nhat HV wrote:
> Hi experts,
>
> I am able to use prolog with JPL. I try to load .pl file from internet, but, some errors occur. What should I do for loading a pl file from internet?
First debug your Prolog code.
JPL is merely reporting an error thrown by consult/1
You can't consult from a URL atom unless you've loaded
library(http/http_load)
Get it working at a Prolog console first.
Good luck
Paul Singleton
> I have taken demo :
>
> —
> JPL.init();
>
> Term consult_arg[] = {
> new Atom(ExampleJPL001.class.getResource(
> "demo001.pl").getPath())
> };
> Query consult_query
> = new Query(
> "consult",
> consult_arg);
>
> boolean consulted = consult_query.hasSolution();
>
> System.out.println("consult " + (consult_query.hasSolution() ? "succeeded" : "failed"));
>
> if (!consulted) {
> System.err.println("Consult failed");
> System.exit(1);
> }
> —
>
> it is OK. But, when I use this code for Java/Servlet:
>
> —
> String filePath = "http://localhost:8080/Website/prolog/demo001.pl";
>
> System.out.println("filePath = " + filePath);
>
> Term consult_arg[] = {
> new Atom(
> filePath)
> };
> Query consult_query
> = new Query(
> "consult",
> consult_arg);
>
> boolean consulted = consult_query.query();
> —
>
> there is the error:
>
> —
> jpl.PrologException: PrologException: error(existence_error(source_sink, 'http://localhost:8080/Website/prolog/demo001.pl'), _0)
> —
>
>
> Best regards,
> Nhat HV.
>
> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>