首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在XPCE中按下按钮后打印函数结果

如何在XPCE中按下按钮后打印函数结果
EN

Stack Overflow用户
提问于 2017-05-14 19:02:35
回答 1查看 280关注 0票数 0

我正试图通过在XPCE中按一个按钮来打印函数结果。这是我的代码:

代码语言:javascript
复制
/* 11) Max square */
max_square(M, A) :-
    findall(P, country(A, P, _, _), L),
    write('Max square in thousands km^2: '),
    aggregate(max(E), member(E, L), M),
    write(M),
    forall(country(A, M,_, _),format(',~w~n', [A])).

:- use_module(library(pce)).

test:-
    new(D, dialog),
    new(W,  window('Test', size(100, 100))),
    send(D, append, new(button(B, max_square, message(@prolog, max_square, M, A)))),
    send(D, below, W),
    send(D, open),
    !.

但是我有这样的错误:http://imgur.com/a/9N546,我如何才能修复它?我的第二个问题是:是否可以在对话框窗口中打印这个结果?提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-14 21:47:18

这是一个可以做的例子。

代码语言:javascript
复制
palindrome :-
    new(D, dialog('Palindrome')),
    new(Etiq, text_item('Is it a palindrome')),
    send(D, append, Etiq),
    new(Result, label),
    send(D, append, Result),
    send(D, append, button(test, message(@prolog, affiche, Etiq, Result))),
    send(D, append, button( cancel, message(D, destroy)) ),
    send(D, open).

affiche(Etiq, Result):-
    get(Etiq, selection, Text),
    atom_codes(Text, Str),
    (   reverse(Str, Str)
    ->   send(Result, selection, 'This is a palindrome')
    ;   send(Result, selection, 'This is not a palindrome')).
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43967759

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档