Frage

I am currently learning Prolog using SWI Prolog. I am able to start prolog with a script file and argument in Linux with the following code:

swipl -s logic1.pl folder1

This starts prolog, loads the .pl file and reads the "folder1" argument.

When I have tried to do the same on my Windows 7 machine via cmd the argument "folder1" doesn't seem to be recognised. I have been launching SWI Prolog with the following command in cmd:

swipl -s logic1.pl folder1

SWI Prolog opens, but the prolog file checks that the correct arguments have been provided and then throws an error message telling me that I need to include the folder1 argument and then closes prolog.

Can anyone tell me how to launch SWI Prolog with the file arguments correctly?

Thanks

War es hilfreich?

Lösung

Short answer: just include -- before folder1.

Long answer:

logic1.pl:

main :-
    current_prolog_flag(argv, AllArgs),
    append(_, [-- | Args], AllArgs),
    writeln(Args).

Run with:

$ swipl -s logic1.pl -t main --quiet -- folder1
[folder1]
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top