morxa
morxa

Reputation: 3374

How to specify the search directory for CLIPS files?

I want to install some CLIPS files to my system so I can load them from any program (e.g., /usr/local/share/clips/foo.clp).

However, it seems that load only looks for a file in the current directory:

CLIPS> (load "/usr/local/share/clips/foo.clp")
TRUE
CLIPS> (load "foo.clp")
[ARGACCES2] Function load was unable to open file foo.clp.
FALSE

How can I specify the search path such that (load "foo.clp") works as expected? Is there a default search directory where I can put my files without setting a search path explicitly?

Upvotes: 0

Views: 1239

Answers (1)

Gary Riley
Gary Riley

Reputation: 10757

In CLIPS 6.4 you can use the chdir command to change the current directory so that you don't have to specify the full path if the file is not in the current directory when CLIPS was launched.

garyriley:R640$ ./clips
         CLIPS (6.4 2/9/21)
CLIPS> (load "/usr/local/share/clips/foo.clp")
*
TRUE
CLIPS> (clear)
CLIPS> (load foo.clp)
[ARGACCES3] Function 'load' was unable to open file 'foo.clp'.
FALSE
CLIPS> (chdir "/usr/local/share/clips")        
TRUE
CLIPS> (load foo.clp)
*
TRUE
CLIPS>

CLIPS doesn't layer anything on top of the C file I/O libraries so the search path is limited to whatever the fopen function uses for its current directory. You could modify the CLIPS source code to set the current directory to a fixed directory or a directory read from a configuration file, but if you want to load files from more than one directory you would still have to specify a full path or use chdir to change the current directory.

Upvotes: 2

Related Questions