Я вызываю файл Пролога из php следующим образом:
Код: Выделить всё
$cmd = "swipl -f /path/to/my_file/prolog.pl -g test,halt -t 'halt(1)'";
exec( $cmd, $output);
print_r($output);
Кто-нибудь знает способ решить мою проблему?
Код моей программы на Прологе выглядит следующим образом:
Код: Выделить всё
start:-
write('-----------------------------------------------------------------------'),
nl,
write(' Welcome'),
nl,
write('-----------------------------------------------------------------------'),
nl,
choices.
choices:-
read_choices,
read(S),
((S == 1; S == one) -> Reply = choice1;
((S == 2; S == two) -> Reply = choice2;
((S == 3; S == three) -> Reply = choice3;
((S == 4; S == four) -> Reply = exit_choice;
(Reply = unknown)
)))),
nl,
(Reply == exit_choice -> exit_from_program;
(Reply == unknown -> (write('Reply not recognized'), start);
(selection(Reply), end_guide(Reply), execute_again('Do you need help?'))
)), nl.
read_choices:-
write('Make a choice:'),
nl,
write('1. Choice 1'),
nl,
write('2. Choice 2'),
nl,
write('3. Choice 3'),
nl,
write('4. Exit'),
nl,
write('Insert choice: ').
execute_again(Text) :-
nl,
write(Text),
nl,
read(S),
((S==s ; S == si) -> start;
((S == n ; S == no) -> exit_from_program; (write('Reply not recognized'), execute_again(Text))
)).
end_guide(R):-
nl,nl,nl,
write(R), write(' ended'), nl.
exit_from_program:-
write('Exit, Bye'),nl.
exit_from_program:-
write('Closed by the user'),nl.
selection(choice1):-
write('choice1 selected').
selection(choice2):-
write('choice2 selected').
selection(choice3):-
write('choice3 selected').
Подробнее здесь: https://stackoverflow.com/questions/790 ... -functions