CLIPS load and run program from file
Asked Answered
V

1

8

I'm using CLIPS (http://clipsrules.sourceforge.net/) for a university project, but I cannot run program directly from files, in this case I don't want to use the prompt to insert FACTS and RULES.

right now I'm doing this.

  1. I open CLIPS ... CLIPS> appear on prompt
  2. Load the file (load "FILE_PATH")
  3. All FACTS, Rules and defFacts were inserted
  4. Type (run) to let the program run and applies rules
Vasta answered 8/8, 2014 at 20:24 Comment(0)
J
15

Place the commands you want executed in a file. For example, the contents of run.bat is the following:

(load file1.clp)
(load file2.clp)
(reset)
(run)

If you're using a command line version, you can execute the contents of the batch file using one of the following two commands:

clips -f run.bat
clips -f2 run.bat

Using the -f option will echo the commands to the command prompt. Using the -f2 option will execute the commands without echoing the commands to the command prompt.

Alternately, you can also embed CLIPS within a C program as described within the Advanced Programming Guide, http://clipsrules.sourceforge.net/OnlineDocs.html.

Jeremiahjeremias answered 9/8, 2014 at 0:45 Comment(3)
In your if you load file1 and file2, you will get in memory all facts and rules in memory right, so when you (run) it will trigger all the rules and deffacts ?Vasta
The (reset) command will assert all facts contained within your deffacts constructs. The (run) command will then begin execution of rules based on the previously asserted facts.Jeremiahjeremias
You can add (unwatch compilations) to get a less verbose output when using (load)Ivette

© 2022 - 2024 — McMap. All rights reserved.