Prolog script

Hello,
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 :-    
    command_lines_options

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
Dominique

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 file.pl ...). Make sure the directory holding libswipl.dll is in %PATH%.
  • Write a .bat file that calls swipl.exe myfile.pl

Hello Jan,

Thanks for your answer.

If I use a .bat file
swipl.exe myfile.pl
how can I give options to myfile.pl ?

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

Thanks
Dominique

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

swipl myfile.pl -- $*

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