Search code examples
c++clips

getting error RULECSRT3 Previous variable bindings of


From clips official documentation I see the following

"The restriction string for a function requiring exactly six arguments (of which the first must be a string, the third an integer, and the remaining arguments floats) is:
"66fsui" "

Can somebody make me understand what does that mean and how the above statement is valid?

Actually I am getting an error while trying to change 3rd parameter from integer to string.. previously is_configured takes "33iiii", now I changed it to "33iisi"

This is the code I have changed, previouly it was working fine.. working code I have it commented in the below lines

    (object (is-a VEHICLE)
            (NUMBER   1) 
            (IDX      ?ID_X)   
            (IDY      ?ID_Y)
            ;; not using ID_Z in the call below and using STRING_Z
            (IDZ    ?ID_Z)
            (STRINGZ ?STRING_Z)
    )

   =>
   (if (is_configured ?ID_X ?ID_Y ?STRING_Z) then
   ;;(if (is_configured ?ID_X ?ID_Y ?ID_Z) then
      (assert (ELIGIBLE_FOR_CALCULATION ?ID_X ?ID_Y ?ID_Z))
   )

And the C++ code is like this

    bool clips_is_configured()
    {
    DATA_OBJECT doTemp;
    long id_x= 0;
    long id_y = 0;
    std::string string_z;
    //long id_z = 0;


    if (ArgCountCheck("is_configured", EXACTLY, 3) == -1)
            return -1;


    if (ArgTypeCheck("is_configured", 1, INTEGER, &doTemp) == 0)
            return -1;
    id_x = (long) DOToLong(doTemp);


    if (ArgTypeCheck("is_configured", 2, INTEGER, &doTemp) == 0)
            return -1;
    id_y = (long) DOToLong(doTemp);


    // if (ArgTypeCheck("is_configured", 3, INTEGER, &doTemp) == 0)
    if (ArgTypeCheck("is_configured", 3, STRING, &doTemp) == 0)
            return -1;
    string_z = DOToString(doTemp);
    //id_z = (long) DOToLong(doTemp);

    bool x;
    ...........
    // do some calulations based on above values and return bool
    ...........
    return x;
    }

I am getting the following error

    [RULECSTR3] Previous variable bindings of ?ID_Y caused the type restrictions for argument #2 of the expression (is_configured ?ID_X ?ID_Y ?STRING_Z) found in the rule's RHS to be violated.

Solution

  • Actually I have given the wrong format... the correct format is "33iiis" the first i indicates default type for parameters if not given

    the second i indicates the type of first parameter

    the third i indicates the type of second parameter

    the first s indicates the type of third parameter

    Thanks