Prolog script

The shebang #! seems not working on Windows,
so How could I tell Windows where it finds swipl ?

More precisly, my Prolog script is

#! /usr/bin/swipl

:- initialization top.

top :-    

where command_lines_options reads the options provided by the user
I also tried :

#! "c:\user\programs\swipl\bin\swipl.exe"

that did not succeed.

Thanks a lot

You will probably need to add swipl to your search path by adding it to the environment variable in the control panel, or looking up how to do it via Powershell. You might also associate your prolog scripts with a particular file extension, so Windows doesn’t confuse prolog files ending in *.pl with Perl scripts.

Couldn’t you also just compile the Prolog program and add it to the PATH directly?

Thanks for your anwser.

swipl is already in my path, when I run my script on a terminal,
windows edits the script but does not run it.
I am not familiar with Windows, may be I missed something…

Thanks again

Handling #! is a Unix facility. Won’t work on Windows. If you associate “.pl” files with swipl-win.exe you can double click them in the Windows explorer to open and run them. If you need a real executable program you have two options:

  • Use a saved state (swipl.exe -o myexe -c ...). Make sure the directory holding libswipl.dll is in %PATH%.
  • Write a .bat file that calls swipl.exe

Hello Jan,

Thanks for your answer.

If I use a .bat file
how can I give options to ?

In my original prolog script under Ubuntu, reads the arguments
provided by the user in the terminal


You can just put the arguments after, to avoid ambiguities separated using --. In a POSIX shell that looks like

swipl -- $*

but don’t ask me how you pass on arguments in Windows bat scripts.