Menu

Check if a substring is contained in a string CLIPS C++

Help
2022-07-21
2022-07-22
  • Felice Avitto

    Felice Avitto - 2022-07-21

    Hi there,
    I'm looking for a way to check if a substring is contained in a string using CLIPS in C++, but at the moment i can't find a solution for it.

    I was reading the advanced documentation guide and i found a reference to str-index, which gives me an INTEGER of the position if the substring matches inside the string or FALSE otherwise.

    However this function is present only in CLIPS command line and it hasn't a corresponding construct to be used in C++. The only function present in strngfun.c/.h is the following,

    void StrIndexFunction(
    Environment theEnv,
    UDFContext
    context,
    UDFValue *returnValue)

    but it's a void function and I need to save the return value (INTEGER or FALSE) to trigger some operations. Moreover, i haven't either UDFcontext or UDFValue.

    Any hints about this topic?

    Thanks in advance.

    Best Regards.

    Felice Avitto

     
    • Gary Riley

      Gary Riley - 2022-07-21

      Construct a string on the C++ side containing your str-index function call and then pass that to the Eval function. That will evaluate it on the CLIPS side and then you can examine the parameter variable in which the return value is populated on the C++ side.

       
  • Felice Avitto

    Felice Avitto - 2022-07-22

    Solved! Thanks a lot, Gary!

     

Log in to post a comment.