Does Scratchpad have access to an app loaded into Pengines?

#1

If I load an application into my Pengine instance in the manner shown in the documentation:

http://www.swi-prolog.org/pldoc/doc_for?object=section('packages/pengines.html')

:- pengine_application(address_book).
:- use_module(address_book:adress_book_api).

Can I access it via code I write in the Scratchpad and/or SWISH editors provided by the Pengines web page? Or are those two modules in their own name/memory space and have no access to adress_book_api code that was loaded?

Note the spelling of “adress_book_api”. It’s missing a “d”.

#2

Yes, you can specify the application to use in the JS. For example add the following code in pengines root directory.

advent.pl

module(advent,[xyzzy/1]).
xyzzy('Nothing happens.').

appended to load.pl

:- pengine_application(myapp).
:- use_module(myapp:advent).

In the scratchpad, load the Simple example, and change the pengine call to:

var pengine = new Pengine({
                ask: 'xyzzy(X)',
                application: 'myapp',
                onsuccess: handleSuccess
            });

and nothing will happen. :wink:

1 Like