, поэтому я работаю над кодом SWI-Prolog, в основном этот search_restaurant даст названия ресторанов с заданными критериями.
Так что, если я выполню
search_restaurant(500,300,9,7500,seafood,knowledge_based,X).
результат:
ресторан морепродуктов с координатами 500, 300, ориентировочная цена 7500 и рейтинг 9: [ABCRest].
X = [ABCRest].
код:
search_restaurant(Xcoord,Ycoord,DesiredRating,DesiredPrice,DesiredType,Kbfile,RestaurantName) :- kbFile(Kbfile),
processInput(Xcoord, Ycoord, DesiredRating, DesiredPrice, DesiredType, RestaurantName),
format('~w restaurant with coord ~d, ~d estimated price ~w and rating ~d: ~w',
[DesiredType, Xcoord, Ycoord, DesiredPrice, DesiredRating, RestaurantName]).
Теперь я пытаюсь реализовать XPCE Gui для ввода переменных, вот мой код:
start :-
new(D, dialog('ZOMITO', size(800, 800))),
new(H1, dialog_group(' ')),
new(H2, dialog_group(' ')),
send(D, append, H1),
send(D, append, H2),
send(H1, append, new(Kbfile, text_item('Input knowledge based file name:'))),
new(Xcoord, text_item('Input your location coordinate(x):')),
new(Ycoord, text_item('Input your location coordinate(y)')),
new(DesiredRating, text_item('Input your desired rating (ex:2 to 4):')),
new(DesiredPrice, text_item('Input your desired price range (ex:100000 to 200000):')),
new(DesiredType, text_item('Input your desired restaurant type (ex:javanese):')),
new(RestaurantName, text_item('Input your desired restaurant name:')),
send(H2, append, Xcoord),
send(H2, append, Ycoord),
send(H2, append, DesiredRating),
send(H2, append, DesiredPrice),
send(H2, append, DesiredType),
send(H2, append, RestaurantName),
send(Xcoord, type, int),
send(Ycoord, type, int),
send(D, append,
button(search, message(@prolog, search_restaurant,
Xcoord?selection,
Ycoord?selection,
DesiredRating?selection,
DesiredPrice?selection,
DesiredType?selection,
Kbfile?selection,
RestaurantName?selection))),
send(D, default_button, search),
send(D, open).
Но он не отображается в консоли, как будто я вызываю search_restaurant вручную. Любая помощь? Что мне не хватает? Спасибо!