Xarray Logic Server Extension Sample

Xarray is a simple example of a Logic Server eXtension (LSX) shared object (dll or so). It implements, in C, three predicates for dealing with arrays from Prolog. The program is built as a DLL under Windows and a shared object under Unix.

Building the Sample Under Windows

Under Windows, open up Visual C++ and build the project xarray.dsw. If you don't have Visual C++, you can create a project in the C development tool of your choice, with the following parameters:

Building the Sample Under Unix

  1. Use the makefile, makefile.lnx, to build xarray.lsx in the source directory.
    make -f makefile.lnx

Running the Sample

Given that xarray.lsx built correctly in the xarray directory, you need to ensure that it gets loaded by Prolog. One way to do this is by having the following line in amzi.cfg, which is how the sample is configured:

lsxload = xarray

test the program from alis:

alis

Under Windows you'll see a message box appear indicating the xarray was loaded OK.

Then consult and run the test program, xarray.pro, which creates an array, sets and gets two values, and deletes the array:

?- [xarray].
yes
?- main.
element 3 is 9
element 4 is 16