1) How I can change my database (facts) using buttons and text fields in XPCE? For example, I have a set of facts:
country('Austria',84,8200,3900).
country('Belgium',30,10300,36500).
country('Bulgaria',1111,7323,11800).
country('United_Kingdom',245,60776,35300).
% and so on
And I've made some groups with GUI for change, edit or delete existing fact:
new(AddNewName, text_item('Enter new country here:')),
new(AddNewPop, text_item('Enter new country population:')),
new(AddNewArea, text_item('Enter new country area:')),
new(AddNewGDP, text_item('Enter new country GDP:')),
send(H10, append, AddNewName),
send(H10, append, AddNewPop),
send(H10, append, AddNewArea),
send(H10, append, AddNewGDP),
send(H10, append, button(add)), %message(@prolog, memberCountry, Etiq, Result))), what should be here?
send(H10, alignment, left),
new(EditNewName, text_item('Enter country here:')),
new(EditNewPop, text_item('Enter new country population:')),
new(EditNewArea, text_item('Enter new country area:')),
new(EditNewGDP, text_item('Enter new country GDP:')),
send(H11, append, EditNewName),
send(H11, append, EditNewPop),
send(H11, append, EditNewArea),
send(H11, append, EditNewGDP),
send(H11, append, button(edit)), %message(@prolog, memberCountry, Etiq, Result))), what should be here?
send(H11, alignment, left),
new(DeleteNewName, text_item('Enter country name here:')),
send(H12, append, DeleteName),
send(H12, append, button(delete)), %message(@prolog, memberCountry, Etiq, Result))), what should be here?
send(H12, alignment, left),
So, how I should construct my buttons messages?
2) And my second question is why I cant see the result of my deep-first search? Here is my GUI code and fucntion:
new(Path1, text('6) Path form-to (serach in deep)')),
new(From1, text_item('Enter country FROM here:')),
new(To1, text_item('Enter country TO here:')),
send(H2, append, Path1),
send(H2, append, From1),
send(H2, append, To1),
new(Path1Res, list_browser),
send(H2, append, button(path, message(@prolog, dfs, From1?selection, To1?selection, [], [], Path1Res))),
send(H2, append, Path1Res),
send(Path1Res, alignment, center),
%...
dfs(From, To, _, [(From, To)]):-
border(From, To).
dfs(From, To, VisitedNodes, [(From, X)|TailPath], Path1):-
border(From, X),
not(member(X, VisitedNodes)),
dfs(X, To, [From|VisitedNodes], TailPath),
send(Path1, append, TailPath).
Thanks in advance!
For the first question, I think you should read the database from a file country.pl, declare predicate country/4 as dynamic, and save the whole database at the end of the program.
May be :
For
Here is an example of what can be done (Question 2)
EDIT1 To save the new bdd you can do :
EDIT2
I suppose that Way is a list of this kind [paris, calais, dover, london], you can do