I'm having a strange problem where I'm creating a COOL instance, running the engine, retrieving an instance slot value that was set via rules. Then I reset the engine, create another COOL instance (of the same name), run the engine again where the rules set the slot value to a different value. But this time, when I use EnvDirectGetSlot and DataObjectToString to retrieve the slot value, I actually get the slot value from the prior run. This pattern appears to continue…I'm always getting the slot value from the previous run, not the current run.
Code snippet is:
SHORT CLIPSRuleService::executeRuleset( const String& ruleSetName, ArrayList& bomObjs, SHORT numOfRulesToFire )
VOID *clpsCardPtr = NULL;
Object *arrayObject = NULL;
String strSlot = "";
engineEnv = getEnvironment(ruleSetName);
for (idx=0; idx < bomObjs.size(); idx++)
// Process each BOM objects
arrayObject = bomObjs.get( idx );
if ( NULL != arrayObject )
if ( NULL != dynamic_cast< String * >( arrayObject ) )
objStr = arrayObject->toString(objStr);
// Reset the Environment
clpsCardPtr = EnvMakeInstance(engineEnv, (char *)objStr.toCharArray());
//Executing the ruleset
//Retrieve the Slot Value
EnvDirectGetSlot(engineEnv, clpsCardPtr, (char *) "FloorLimit", &slotValue);
//Convert the Data Object to String
strSlot = DataObjectToString(engineEnv, &slotValue);
Oh, and here's my class definition:
(defclass Card (is-a USER)
(slot CardNumber (type STRING))
(slot FloorLimit (type STRING))
Use the EnvWatch function to watch rules, instances, and slots, so that you can observe changes as you create the instance and run your rules. I don't see anything obviously wrong with the code.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.