Subject: [SWIPL] Newbie question for XPCE

From: João Mariz <[email-masked]>
Date: Fri, 18 May 2001 20:16:27 +0100

Hello SwiProlog users;

I have done some work with SWI PROLOG. Now I am trying to do something
with XPCE so that my application becames more pretty.
I have developped a simple predicate [called city/0] that selectes text
from a list. I write it above:

city:-
       new(C, dialog('Select a City')),
       send(C, append, new(LB, list_browser)),
       send(LB, width,  28),
            add_cities(LB),
       send(C, append,
                   new(Bts, dialog_group('Options')), below),
       send(Bts, append, button(quit, message(C, destroy))),
       send(Bts, append, button(ok, message(@prolog, listar,
LB?selection?key, C), right )),
       send(C, open) .

listar(L, C):-
       get(L, name, Text_item),
       nl,  nl,  write('The city is '), write(Text_item), nl, nl,
       send(C, destroy) .

add_cities(LB):-
        send(LB, append, new(Ti1, text_item('Abrantes', 'Abrantes'))),
        send(LB, append, new(Ti2, text_item('Coimbra', 'Coimbra'))),
        send(LB, append, new(Ti3, text_item('Lisboa', 'Lisboa'))),
        send(LB, append, new(X1, text_item('Golegã', 'golega'))),
        send(LB, append, new(X2, text_item('Salva Terra de Magos',
'salva terra de magos'))),
        send(LB, append, new(Xl3, text_item('Chamusca',  'chamusca'))),
        send(LB, append, new(X4, text_item('Santarém',  'santarem'))),
        send(LB, append, new(S1, text_item('Porto', 'porto'))),
        send(LB, append, new(B2, text_item('Faro', 'faro'))),
        send(LB, append, new(N3, text_item('Évora',  'evora'))),
        send(LB, append, new(C4, text_item('Beja',  'beja'))), ! .

However, after querying with city/0 predicate, when I select both, the
text from the list_browser and the ok button, I do not get a "yes"
answer on my XPCE ?- prompt. Perhaps I did not finnish city/0 predicate.

If I have a city/0 predicate inside another predicate I get the answer
"no" at the XPCE '- prompt and I still have my XPCE window open.
How can I have a Yes answer? or pursuit with the city/0 predicate until
it finnishes?

Thanks in advance for any help you can provide,

João