/************************************************************************** OkWatchCallback Description: This function will reset the watch flags to the new values and remove the watch window from the screen. Arguments: w - widget that event was activated client_data - NULL call_data - Unused Return: None **************************************************************************/ void OkWatchCallback( Widget w, XtPointer client_data, XtPointer call_data) { void *theEnv = GetCurrentEnvironment(); int i,n; Boolean OnOff = False; for(i = 0; i< MAX_WATCH; i++) { n = 0; XtSetArg(TheArgs[n],XtNstate,&OnOff);n++; XtGetValues(watch_widgets[i],TheArgs,n); /*----------------------------------------------------------------*/ /* I have to do this because I am not sure if True and False in X */ /* are defined the same as CLIPS_TRUE and CLIPS_FALSE */ /*----------------------------------------------------------------*/ if((OnOff == True)&&(EnvGetWatchItem(theEnv,WatchName[i])!= CLIPS_TRUE)) { EnvSetWatchItem(theEnv,WatchName[i], ON,NULL); } else if((OnOff == False) && (EnvGetWatchItem(theEnv,WatchName[i]) == CLIPS_TRUE)) { EnvSetWatchItem(theEnv,WatchName[i], OFF,NULL); } } XtPopdown(XtParent(XtParent(w))); quit_get_event = True; }
globle int SetWatchItem( const char *itemName, unsigned newState, struct expr *argExprs) { return EnvSetWatchItem(GetCurrentEnvironment(),itemName,newState,argExprs); }
globle void UnwatchCommand( void *theEnv) { DATA_OBJECT theValue; char *argument; int recognized; struct watchItem *wPtr; /*==========================================*/ /* Determine which item is to be unwatched. */ /*==========================================*/ if (EnvArgTypeCheck(theEnv,"unwatch",1,SYMBOL,&theValue) == FALSE) return; argument = DOToString(theValue); wPtr = ValidWatchItem(theEnv,argument,&recognized); if (recognized == FALSE) { SetEvaluationError(theEnv,TRUE); ExpectedTypeError1(theEnv,"unwatch",1,"watchable symbol"); return; } /*=================================================*/ /* Check to make sure extra arguments are allowed. */ /*=================================================*/ if (GetNextArgument(GetFirstArgument()) != NULL) { if ((wPtr == NULL) ? TRUE : (wPtr->accessFunc == NULL)) { SetEvaluationError(theEnv,TRUE); ExpectedCountError(theEnv,"unwatch",EXACTLY,1); return; } } /*=====================*/ /* Set the watch item. */ /*=====================*/ EnvSetWatchItem(theEnv,argument,OFF,GetNextArgument(GetFirstArgument())); }
globle intBool EnvUnwatch( void *theEnv, char *itemName) { return(EnvSetWatchItem(theEnv,itemName,OFF,NULL)); }
static void RestoreWatchInformation() { HKEY hKey; DWORD lpdwDisposition; struct WatchInformation watchInfo; DWORD type = REG_BINARY; DWORD size = sizeof(struct WatchInformation); if (RegCreateKeyEx(HKEY_CURRENT_USER,TEXT("Software\\CLIPS\\CLIPSWin"),0,"",0, KEY_READ | KEY_WRITE,NULL,&hKey,&lpdwDisposition) != ERROR_SUCCESS) { return; } if (RegQueryValueEx(hKey,"Watch",0,&type,(BYTE *) &watchInfo, &size) != ERROR_SUCCESS) { RegCloseKey(hKey); return; } EnvSetWatchItem(GlobalEnv,"compilations",watchInfo.compilations,NULL); EnvSetWatchItem(GlobalEnv, "facts", watchInfo.facts, NULL); EnvSetWatchItem(GlobalEnv, "instances", watchInfo.instances, NULL); EnvSetWatchItem(GlobalEnv, "rules", watchInfo.rules, NULL); EnvSetWatchItem(GlobalEnv, "generic-functions", watchInfo.genericFunctions, NULL); EnvSetWatchItem(GlobalEnv, "messages", watchInfo.messages, NULL); EnvSetWatchItem(GlobalEnv, "deffunctions", watchInfo.deffunctions, NULL); EnvSetWatchItem(GlobalEnv, "statistics", watchInfo.statistics, NULL); EnvSetWatchItem(GlobalEnv, "globals", watchInfo.globals, NULL); EnvSetWatchItem(GlobalEnv, "slots", watchInfo.slots, NULL); EnvSetWatchItem(GlobalEnv, "activations", watchInfo.activations, NULL); EnvSetWatchItem(GlobalEnv, "methods", watchInfo.methods, NULL); EnvSetWatchItem(GlobalEnv, "focus", watchInfo.focus, NULL); EnvSetWatchItem(GlobalEnv, "message-handlers", watchInfo.messageHandlers, NULL); RegCloseKey(hKey); }
globle intBool EnvWatch( void *theEnv, const char *itemName) { return(EnvSetWatchItem(theEnv,itemName,ON,NULL)); }