質問

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

役に立ちましたか?

解決

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]
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top