Force Constant
Force Constant

Reputation: 1

Using CLIPS c library, how can I change where Watches are printed/written to?

If I do something like Watch(theEnv, FACTS);, the default is this debug gets written to STDOUT, and doesn't look like I can change that. I would like to write this to a seperate file, how can I do this? This is using. 6.41 CLIPS

Using ' Watch(theEnv, FACTS);' has stuff printed to STDOUT, but need to write to different file.

Upvotes: 0

Views: 20

Answers (1)

Gary Riley
Gary Riley

Reputation: 10757

There's no mechanism for changing the where the watch information is written. You can use the dribble-on/dribble-off functions to capture I/O sent to STDIN/STDOUT, but that will capture all I/O to STDIN/STDOUT.

You'd have to modify the CLIPS source code to redirect the output. There's two spots in factmngr.c that print the watch information for facts:

  WriteString(theEnv,STDOUT,"==> ");
  PrintFactWithIdentifier(theEnv,STDOUT,theFact,changeMap);
  WriteString(theEnv,STDOUT,"\n");

  WriteString(theEnv,STDOUT,"<== ");
  PrintFactWithIdentifier(theEnv,STDOUT,theFact,changeMap);
  WriteString(theEnv,STDOUT,"\n");

You'd have replace STDOUT with a char * variable initially set to STDOUT and then add a user-defined function which allows you to set that variable to a different string. You could then use the open function to open a file and then set the variable to the logical name used in the open function.

Upvotes: 0

Related Questions