【问题标题】:Why doesnot absolute_file_name work为什么绝对文件名不起作用
【发布时间】:2013-03-01 07:28:55
【问题描述】:

以下代码在 swi-prolog 中工作:

:- asserta(user:file_search_path(money, '/media/D/db')).
dataFile(F) :-
absolute_file_name(money('test.dat'), F, []).

gprolog 中似乎没有模块。我怎样才能让它在 gprolog 下工作?

真诚的!

【问题讨论】:

    标签: gnu-prolog


    【解决方案1】:

    您没有提供足够的详细信息,但我推断问题在于运算符 ':-' 尝试使用 'initialization/1'

    $ cat > file.pl
    
    initialization(asserta(user:file_search_path(money, '/media/D/db'))).
    dataFile(F) :- absolute_file_name(money('test.dat'), F, []).
    ^d
    
    $ gprolog --init-goal "['file.pl']"
    compiling /Users/user/file.pl for byte code...
    /Users/user/file.pl compiled, 2 lines read - 763 bytes written, 8 ms
    GNU Prolog 1.4.1
    By Daniel Diaz
    Copyright (C) 1999-2012 Daniel Diaz
    | ?- 
    

    希望这项工作......

    【讨论】:

    • 咨询没问题,但 file_search_path(money,X)。未捕获的异常:error(existence_error(procedure,file_search_path/2),top_level/0) | ?- 数据文件(X)。未捕获的异常:error(existence_error(procedure,absolute_file_name/3),dataFile/1)
    • file_search_path 不是 ISO 指令,它不是由 gnuprolog 实现的。您必须寻找替代方案或实现自己的指令(检查文件处理和操作系统接口)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-06
    • 2012-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多