【问题标题】:SWI-Prolog CGI cgi_get_form(Arguments) web hidden formSWI-Prolog CGI cgi_get_form(Arguments) web 隐藏表单
【发布时间】:2012-05-25 12:43:50
【问题描述】:

我在使用 SWI-Prolog 的 CGI 库传递输入 type="hidden" 表单时遇到问题。具体来说:

<form id="frmCGIPrologIni" name="frmCGIPrologIni" method="post" action="http://localhost/cgi-bin/x.pl"> <p><input type="hidden" name="initial" value="ini" /> <input class="submit" type="submit" value="Start" /> </p></form>

当程序 x.pl 调用 cgi_get_form(Arguments) 时,参数应该是 Name(Value) 术语的列表,即:[Name, Value],所以它应该是 [initial(ini)]。

但是当我使用它时它说:错误:=../2:参数没有充分实例化

print_args([]).
print_args([F|T]) :- % with Arguments
    F =.. [Name, Value], % and should continue doing things

我尝试使用 write(Arguments) 手动打印它,我得到的是:_L160,打印第一个元素是:_G472 和 write_canonical(Arguments) 返回:'.'(_,_)

我也尝试使用 method="get" 来检查它,它会正确打印 URI http://localhost/cgi-bin/x.pl?initial=ini 所以我猜这不是提交问题,而是使用 cgi_get_form(Arguments) 处理的问题。

'http://localhost/cgi-bin/x.pl' 第一次运行时我会这样做:

cgi_get_form(Arguments),

(Arguments = []) ->
(
format('<p>Print this as the index.</p>~n', []),
) ; true, % and it works well because there are no Arguments the first time

write('<p>'), write(Arguments), write('</p>'), nl, % and print other things

问题是第二次了。这次调用同一个程序有参数所以它不打印消息,到这里一切都很好。然后通过 true 并继续。那是我尝试使用之前解释的结果(_L160)编写(参数)的时候。而结果应该是表单传递的数据。

有什么想法吗?

【问题讨论】:

    标签: forms list web prolog swi-prolog


    【解决方案1】:

    你试过了吗

    print_args([F|T]) :- % with Arguments
        F =.. [Name | Value], % and should continue doing things
    

    【讨论】:

      猜你喜欢
      • 2012-05-12
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 2016-01-16
      • 2012-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多