所以我正在研究一个 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 一样。有什么帮助吗?我错过了什么?谢谢!