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,
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.
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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.
Solved! Thanks a lot, Gary!