SWI-Prolog与XPCE Gui集成

时间:2018-05-09 07:31:08

标签: prolog swi-prolog xpce

所以我正在研究SWI-Prolog代码,基本上这个search_restaurant会给出符合条件的餐馆名称。

所以如果我执行

search_restaurant(500,300,9,7500,seafood,knowledge_based,X).

结果:
海鲜餐厅用coord 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一​​样。有帮助吗?我错过了什么?谢谢!

0 个答案:

没有答案