I’m not sure you are talking about SWISH or the older Pengines application? For SWISH the normal way to extend and configure is is to create a directory config-enabled
and copy standard config files from config-available
or add your own. The older Pengines repo is not maintained much.
Hi Jan,
I’m talking about using Pengines from a Javascript client with the Prolog code for my app already loaded on the server side for the client’s use.
My understanding is that I need the following statements to get my application code loaded into Pengines on the server side, so that the predicates I exposed in my main module are available via requests made from client code. In my case, the client is a Node.JS Javascript app that wants to make calls into my application. Here are the calls I believe are necessary to load that code into PEngines on the server side:
pengine_application(my_app),
use_module(my_app:library(main_module))
main_module is my “top level” Prolog source file that contains a module definition for the exported predicates. I don’t know where I should put the two above statements (e.g. - run.pl, INI file, etc.) and if that is everything I need to do to make the predicates exported by main_module available to code that calls into my Pengine instance via the ask() Javascript function:
var pengine = new Pengine({
ask: 'q(X)',
onsuccess: handleSuccess
});
function handleSuccess() {
$('#out').html(this.data[0].X);
if (!this.more) {
$('#next').prop("disabled", true);
}
}
So in my case the code for q() would already be loaded into my Pengines instance on the server side at startup.
Note, I’m assuming I can load my application code on the server side upon startup, instead of passing in the code I want to execute into my Pengines instance like the Scratchpad examples demonstrate. So I don’t want to have HTML code on the client side like:
<script type="text/x-prolog">
q(X) :- p(X).
p(a). p(b). p(c). p(d). p(e). p(f). p(g).
</script>
Instead, using the above sample code, I would want to have already loaded the code to q() and p() on the server side during startup so that the client side code can just call q() without having to define the code it wants my Pengine instance to execute, the code for p() and q() because that code is loaded on the server side during startup.
Do I have this right? Oh heck, after a full day of staring at that code I just got the joke about “minding your P’s and Q’s”.