void GetWatchItemCommand( Environment *theEnv, UDFContext *context, UDFValue *returnValue) { UDFValue theValue; const char *argument; bool recognized; /*========================================*/ /* Determine which item is to be watched. */ /*========================================*/ if (! UDFFirstArgument(context,SYMBOL_BIT,&theValue)) { return; } argument = theValue.lexemeValue->contents; ValidWatchItem(theEnv,argument,&recognized); if (recognized == false) { SetEvaluationError(theEnv,true); ExpectedTypeError1(theEnv,"get-watch-item",1,"'watchable symbol'"); returnValue->lexemeValue = FalseSymbol(theEnv); return; } /*===========================*/ /* Get the watch item value. */ /*===========================*/ if (GetWatchItem(theEnv,argument) == 1) { returnValue->lexemeValue = TrueSymbol(theEnv); } else { returnValue->lexemeValue = FalseSymbol(theEnv); } }
void UnwatchCommand( Environment *theEnv, UDFContext *context, UDFValue *returnValue) { UDFValue theValue; const char *argument; bool recognized; WatchItemRecord *wPtr; /*==========================================*/ /* Determine which item is to be unwatched. */ /*==========================================*/ if (! UDFFirstArgument(context,SYMBOL_BIT,&theValue)) return; argument = theValue.lexemeValue->contents; wPtr = ValidWatchItem(theEnv,argument,&recognized); if (recognized == false) { SetEvaluationError(theEnv,true); UDFInvalidArgumentMessage(context,"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. */ /*=====================*/ SetWatchItem(theEnv,argument,false,GetNextArgument(GetFirstArgument())); }
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 int GetWatchItemCommand( void *theEnv) { DATA_OBJECT theValue; char *argument; int recognized; /*============================================*/ /* Check for the correct number of arguments. */ /*============================================*/ if (EnvArgCountCheck(theEnv,"get-watch-item",EXACTLY,1) == -1) { return(FALSE); } /*========================================*/ /* Determine which item is to be watched. */ /*========================================*/ if (EnvArgTypeCheck(theEnv,"get-watch-item",1,SYMBOL,&theValue) == FALSE) { return(FALSE); } argument = DOToString(theValue); ValidWatchItem(theEnv,argument,&recognized); if (recognized == FALSE) { SetEvaluationError(theEnv,TRUE); ExpectedTypeError1(theEnv,"get-watch-item",1,"watchable symbol"); return(FALSE); } /*===========================*/ /* Get the watch item value. */ /*===========================*/ if (EnvGetWatchItem(theEnv,argument) == 1) { return(TRUE); } return(FALSE); }
globle void ListWatchItemsCommand() { struct watchItem *wPtr; DATA_OBJECT theValue; int recognized; /*=======================*/ /* List the watch items. */ /*=======================*/ if (GetFirstArgument() == NULL) { for (wPtr = ListOfWatchItems; wPtr != NULL; wPtr = wPtr->next) { PrintRouter(WDISPLAY,wPtr->name); if (*(wPtr->flag)) PrintRouter(WDISPLAY," = on\n"); else PrintRouter(WDISPLAY," = off\n"); } return; } /*=======================================*/ /* Determine which item is to be listed. */ /*=======================================*/ if (ArgTypeCheck("list-watch-items",1,SYMBOL,&theValue) == FALSE) return; wPtr = ValidWatchItem(DOToString(theValue),&recognized); if ((recognized == FALSE) || (wPtr == NULL)) { SetEvaluationError(TRUE); ExpectedTypeError1("list-watch-items",1,"watchable symbol"); return; } /*=================================================*/ /* Check to make sure extra arguments are allowed. */ /*=================================================*/ if ((wPtr->printFunc == NULL) && (GetNextArgument(GetFirstArgument()) != NULL)) { SetEvaluationError(TRUE); ExpectedCountError("list-watch-items",EXACTLY,1); return; } /*====================================*/ /* List the status of the watch item. */ /*====================================*/ PrintRouter(WDISPLAY,wPtr->name); if (*(wPtr->flag)) PrintRouter(WDISPLAY," = on\n"); else PrintRouter(WDISPLAY," = off\n"); /*============================================*/ /* List the status of individual watch items. */ /*============================================*/ if (wPtr->printFunc != NULL) { if ((*wPtr->printFunc)(WDISPLAY,wPtr->code, GetNextArgument(GetFirstArgument())) == FALSE) { SetEvaluationError(TRUE); } } }
globle void ListWatchItemsCommand( void *theEnv) { struct watchItem *wPtr; DATA_OBJECT theValue; int recognized; /*=======================*/ /* List the watch items. */ /*=======================*/ if (GetFirstArgument() == NULL) { for (wPtr = WatchData(theEnv)->ListOfWatchItems; wPtr != NULL; wPtr = wPtr->next) { EnvPrintRouter(theEnv,WDISPLAY,wPtr->name); if (*(wPtr->flag)) EnvPrintRouter(theEnv,WDISPLAY,sym_equalson); else EnvPrintRouter(theEnv,WDISPLAY,sym_equalsoff); } return; } /*=======================================*/ /* Determine which item is to be listed. */ /*=======================================*/ if (EnvArgTypeCheck(theEnv,name_listwatchitems,1,SYMBOL,&theValue) == FALSE) return; wPtr = ValidWatchItem(theEnv,DOToString(theValue),&recognized); if ((recognized == FALSE) || (wPtr == NULL)) { SetEvaluationError(theEnv,TRUE); ExpectedTypeError1(theEnv,name_listwatchitems,1,sym_watchable_symbol); return; } /*=================================================*/ /* Check to make sure extra arguments are allowed. */ /*=================================================*/ if ((wPtr->printFunc == NULL) && (GetNextArgument(GetFirstArgument()) != NULL)) { SetEvaluationError(theEnv,TRUE); ExpectedCountError(theEnv,name_listwatchitems,EXACTLY,1); return; } /*====================================*/ /* List the status of the watch item. */ /*====================================*/ EnvPrintRouter(theEnv,WDISPLAY,wPtr->name); if (*(wPtr->flag)) EnvPrintRouter(theEnv,WDISPLAY,sym_equalson); else EnvPrintRouter(theEnv,WDISPLAY,sym_equalsoff); /*============================================*/ /* List the status of individual watch items. */ /*============================================*/ if (wPtr->printFunc != NULL) { if ((*wPtr->printFunc)(theEnv,WDISPLAY,wPtr->code, GetNextArgument(GetFirstArgument())) == FALSE) { SetEvaluationError(theEnv,TRUE); } } }
void ListWatchItemsCommand( Environment *theEnv, UDFContext *context, UDFValue *returnValue) { WatchItemRecord *wPtr; UDFValue theValue; bool recognized; /*=======================*/ /* List the watch items. */ /*=======================*/ if (GetFirstArgument() == NULL) { for (wPtr = WatchData(theEnv)->ListOfWatchItems; wPtr != NULL; wPtr = wPtr->next) { WriteString(theEnv,STDOUT,wPtr->name); if (*(wPtr->flag)) WriteString(theEnv,STDOUT," = on\n"); else WriteString(theEnv,STDOUT," = off\n"); } return; } /*=======================================*/ /* Determine which item is to be listed. */ /*=======================================*/ if (! UDFFirstArgument(context,SYMBOL_BIT,&theValue)) return; wPtr = ValidWatchItem(theEnv,theValue.lexemeValue->contents,&recognized); if ((recognized == false) || (wPtr == NULL)) { SetEvaluationError(theEnv,true); ExpectedTypeError1(theEnv,"list-watch-items",1,"'watchable symbol'"); return; } /*=================================================*/ /* Check to make sure extra arguments are allowed. */ /*=================================================*/ if ((wPtr->printFunc == NULL) && (GetNextArgument(GetFirstArgument()) != NULL)) { SetEvaluationError(theEnv,true); ExpectedCountError(theEnv,"list-watch-items",EXACTLY,1); return; } /*====================================*/ /* List the status of the watch item. */ /*====================================*/ WriteString(theEnv,STDOUT,wPtr->name); if (*(wPtr->flag)) WriteString(theEnv,STDOUT," = on\n"); else WriteString(theEnv,STDOUT," = off\n"); /*============================================*/ /* List the status of individual watch items. */ /*============================================*/ if (wPtr->printFunc != NULL) { if ((*wPtr->printFunc)(theEnv,STDOUT,wPtr->code, GetNextArgument(GetFirstArgument())) == false) { SetEvaluationError(theEnv,true); } } }