Loading files from the same directory

65 views Asked by At

I have clips templates, facts, functions, and rules stored in separate .txt files. In the same directory I have a loader.txt file as shown below that attempts to load these files. Despite changing the directory, I get the unable to load file error. If I modify the paths in the loading function starting from "/users.../directory_with_files/file_name", the logic works without error.

(deffunction loading()
    (load "templates.txt")
    (load "facts.txt")
    (load "functions.txt")
    (load "rules.txt")
)

I would like to load these files in the same directory as loader.txt without specifying the path explicitly i.e., "/users.../directory_with_files/file_name"

1

There are 1 answers

3
Gary Riley On BEST ANSWER

I wasn't able to reproduce the issue using the console version of CLIPS on either Windows, macOS, or Ubuntu. Here's the output on Windows:

C:\Users\garyriley\Desktop\clips_core_source_641\core>clips
         CLIPS (6.4.1 4/8/23)
CLIPS> (system "cd")
C:\Users\garyriley\Desktop\clips_core_source_641\core
0
CLIPS> (load hello.clp)
[ARGACCES3] Function 'load' was unable to open file 'hello.clp'.
FALSE
CLIPS> (chdir "C:/Users/garyriley/Desktop/clips_core_source_641")
TRUE
CLIPS> (load hello.clp)
*
TRUE
CLIPS> (system "cd")
C:\Users\garyriley\Desktop\clips_core_source_641
0
CLIPS>

Here's the output on Ubuntu:

parallels:core$ ./clips
         CLIPS (6.4.1 4/8/23)
CLIPS> (system "pwd")
/home/parallels/Desktop/clips_core_source_641/core
0
CLIPS> (load hello.clp)
[ARGACCES3] Function 'load' was unable to open file 'hello.clp'.
FALSE
CLIPS> (chdir /home/parallels/Desktop/clips_core_source_641) 
TRUE
CLIPS> (load hello.clp)
*
TRUE
CLIPS> (system "pwd")
/home/parallels/Desktop/clips_core_source_641
0
CLIPS>