AssertString function in C++

26 views
Skip to first unread message

Diana Chen

unread,
Jun 1, 2020, 9:30:30 PM6/1/20
to CLIP...@googlegroups.com
Hello,

I have a question about the AssertString function being used in C++. I'm writing a c++ wrapper using clips. I'm fairly new to both c++ and clips, so I may be misunderstanding some fundamentals.

the section where I use AssertString looks like:
 if (true) {
      char *factptr =  &(fact[0]);
       EnvAssertString(theEnv, factptr);

I input a string "(color-red)" and the wrapper seems to throw no errors.
However, I'm not sure if this is correct or not. I tried using EnvGetFactsListschanged, but the CLIPS just returns a number.

Is there a way to print out the current list of facts in c++? Is there a standard template the AssertString function must have as an input?

thanks,

Diana

CLIPS Support

unread,
Jun 3, 2020, 2:58:38 PM6/3/20
to CLIPSESG
In your example it's not clear the type that fact[0] would be, but the simplest call you could make to use the EnvAssertString function would be

EnvAssertString(theEnv,"(color-red)");

You can use the EnvEval function to issue commands as if you had entered them at the CLIPS command prompt. Here's a simple example:

int main(

  int argc,

  char *argv[])

  {

   void *theEnv;

   DATA_OBJECT rv;


   theEnv = CreateEnvironment();

   

   EnvAssertString(theEnv,"(color-red)");

   EnvEval(theEnv,"(facts)",&rv);

      

   return 0;

Diana Chen

unread,
Jun 3, 2020, 5:19:47 PM6/3/20
to clip...@googlegroups.com, garyd...@gmail.com
Hello,

thank you! the EnEval function is great. What is the rv object for?

Diana

--
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To post to this group, send email to CLIP...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en
 
--> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Click on "Edit my membership" link.
Select the "No Email" radio button.
Click the "Save these settings" button.

--> IF YOU WANT TO UNSUBSCRIBE <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Sign in
Click on "Edit my membership" link.
Click the "Unsubscribe" button.
Note: This appears to be the most reliable way to unsubscribe
 
Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.
---
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clipsesg+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clipsesg/f4ddf7c7-fd30-4b4b-bb8c-e089171d2aa0%40googlegroups.com.

CLIPS Support

unread,
Jun 4, 2020, 12:59:16 PM6/4/20
to CLIPSESG
If the command has a return value, it’s stored in the DATA_OBJECT variable rv. The facts command has no return valuek, so nothing is going to be stored there, but if you did call a function that returned a value you’d look at that variable to retrieve the value. This is explained in greater detail in the CLIPS Advanced Programming Guide: http://www.clipsrules.net/Documentation.html

On Wednesday, June 3, 2020 at 4:19:47 PM UTC-5, Diana Chen wrote:
Hello,

thank you! the EnEval function is great. What is the rv object for?

Diana
Alternately, send email to CLIPSESG-unsubscribe@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.

---
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clipsesg+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages