为什么当我单击SUM按钮时什么也没发生?

时间:2018-12-18 17:03:17

标签: prolog xpce

我试图使用XPCE在Prolog中建立界面。我使用的是Dialog Editor,它在Prolog中生成了我的代码。当我单击SUM按钮时,什么也没发生,我不明白为什么,但是我认为问题是sum子句。

DialogEditor

dialog(zbrajanje,
   [ object        :=
       Zbrajanje,
     parts         :=
       [ Zbrajanje   :=
           dialog('Zbrajanje'),
         Unesi       :=
           button(unesi),
         Odustani    :=
           button(odustani),
         Text_item_1 :=
           text_item(text_item1),
         Text_item_2 :=
           text_item(text_item2),
         Rezultat    :=
           text_item('Rezultat')
       ],
     modifications :=
       [ Text_item_1 := [ length := 26
                        ]
       ],
     layout        :=
       [ area(Unesi,
              area(52, 148, 80, 24)),
         area(Odustani,
              area(224, 146, 80, 24)),
         area(Text_item_2,
              area(66, 39, 260, 24)),
         area(Text_item_1,
              area(66, 63, 260, 24)),
         area(Rezultat,
              area(67, 90, 246, 24))
       ],
     behaviour     :=
       [ SUM    := [ message := message(@prolog,
                                          sum,
                                          Text_item_2?selection,
                                          Text_item_1?selection,
                                          Rezultat)
                     ],
         EXIT := [ message := message(Zbrajanje, return, @nil)
                     ]
       ]
   ]).

sum(X,0,X).
sum(X,Y,S):-
S = X+Y.

inic(Var) :- make_dialog(D,zbrajanje ),
    get(D, confirm_centered, R),
    send(D,destroy),
    Var = R.

1 个答案:

答案 0 :(得分:0)

您对sum/3谓词的定义不正确。 =/2谓词/运算符在词之间执行统一。您需要算术评估,它使用is/2谓词/运算符。请尝试:

..., S is X + Y.