globle void *SetSalienceEvaluationCommand( void *theEnv) { DATA_OBJECT argPtr; char *argument, *oldValue; /*==================================================*/ /* Get the current setting for salience evaluation. */ /*==================================================*/ oldValue = SalienceEvaluationName(EnvGetSalienceEvaluation(theEnv)); /*=========================================*/ /* This function expects a single argument */ /* which must be a symbol. */ /*=========================================*/ if (EnvArgCountCheck(theEnv,(char*)"set-salience-evaluation",EXACTLY,1) == -1) { return((SYMBOL_HN *) EnvAddSymbol(theEnv,oldValue)); } if (EnvArgTypeCheck(theEnv,(char*)"set-salience-evaluation",1,SYMBOL,&argPtr) == FALSE) { return((SYMBOL_HN *) EnvAddSymbol(theEnv,oldValue)); } /*=============================================================*/ /* The allowed symbols to pass as an argument to this function */ /* are when-defined, when-activated, and every-cycle. */ /*=============================================================*/ argument = DOToString(argPtr); if (strcmp(argument,(char*)"when-defined") == 0) { EnvSetSalienceEvaluation(theEnv,WHEN_DEFINED); } else if (strcmp(argument,(char*)"when-activated") == 0) { EnvSetSalienceEvaluation(theEnv,WHEN_ACTIVATED); } else if (strcmp(argument,(char*)"every-cycle") == 0) { EnvSetSalienceEvaluation(theEnv,EVERY_CYCLE); } else { ExpectedTypeError1(theEnv,(char*)"set-salience-evaluation",1, (char*)"symbol with value when-defined, when-activated, or every-cycle"); return((SYMBOL_HN *) EnvAddSymbol(theEnv,oldValue)); } /*=================================================*/ /* Return the old setting for salience evaluation. */ /*=================================================*/ return((SYMBOL_HN *) EnvAddSymbol(theEnv,oldValue)); }
static void RestoreExecutionInformation() { HKEY hKey; DWORD lpdwDisposition; struct ExecutionInformation executionInfo; DWORD type = REG_BINARY; DWORD size = sizeof(struct ExecutionInformation); if (RegCreateKeyEx(HKEY_CURRENT_USER,TEXT("Software\\CLIPS\\CLIPSWin"),0,"",0, KEY_READ | KEY_WRITE,NULL,&hKey,&lpdwDisposition) != ERROR_SUCCESS) { return; } if (RegQueryValueEx(hKey,"Execution",0,&type,(BYTE *) &executionInfo, &size) != ERROR_SUCCESS) { RegCloseKey(hKey); return; } EnvSetSalienceEvaluation(GlobalEnv,executionInfo.salienceEvaluation); EnvSetStrategy(GlobalEnv,executionInfo.strategy); EnvSetStaticConstraintChecking(GlobalEnv,executionInfo.staticConstraintChecking); EnvSetDynamicConstraintChecking(GlobalEnv,executionInfo.dynamicConstraintChecking); EnvSetAutoFloatDividend(GlobalEnv,executionInfo.autoFloatDividend); EnvSetResetGlobals(GlobalEnv,executionInfo.resetGlobals); EnvSetFactDuplication(GlobalEnv,executionInfo.factDuplication); EnvSetIncrementalReset(GlobalEnv,executionInfo.incrementalReset); EnvSetSequenceOperatorRecognition(GlobalEnv,executionInfo.sequenceOperatorRecognition); RegCloseKey(hKey); }
globle void EnvRefreshAgenda( void *theEnv, void *vTheModule) { struct activation *theActivation; struct defmodule *theModule = (struct defmodule *) vTheModule; intBool oldValue; int allModules = FALSE; /*==========================*/ /* Save the current module. */ /*==========================*/ SaveCurrentModule(theEnv); /*=============================================*/ /* If the module specified is a NULL pointer, */ /* then every module has its agenda refreshed. */ /*=============================================*/ if (theModule == NULL) { allModules = TRUE; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); } /*=======================================================*/ /* Remember the current setting for salience evaluation. */ /* To perform the refresh, the when activated setting is */ /* used to recompute the salience values. */ /*=======================================================*/ oldValue = EnvGetSalienceEvaluation(theEnv); EnvSetSalienceEvaluation(theEnv,WHEN_ACTIVATED); /*========================*/ /* Refresh the agenda(s). */ /*========================*/ for (; theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule)) { /*=========================================*/ /* Change the current module to the module */ /* of the agenda being refreshed. */ /*=========================================*/ EnvSetCurrentModule(theEnv,(void *) theModule); /*================================================================*/ /* Recompute the salience values for the current module's agenda. */ /*================================================================*/ for (theActivation = (struct activation *) EnvGetNextActivation(theEnv,NULL); theActivation != NULL; theActivation = (struct activation *) EnvGetNextActivation(theEnv,theActivation)) { theActivation->salience = EvaluateSalience(theEnv,theActivation->theRule); } /*======================================================*/ /* Reorder the agenda based on the new salience values. */ /*======================================================*/ EnvReorderAgenda(theEnv,theModule); /*===============================================*/ /* Return if only one agenda is being refreshed. */ /*===============================================*/ if (! allModules) { EnvSetSalienceEvaluation(theEnv,oldValue); RestoreCurrentModule(theEnv); return; } } /*==========================================*/ /* Restore the salience evaluation setting. */ /*==========================================*/ EnvSetSalienceEvaluation(theEnv,oldValue); /*=============================*/ /* Restore the current module. */ /*=============================*/ RestoreCurrentModule(theEnv); }