Menu

#13 (get-watch-item all) always returns false

CLIPS
closed
None
5
2024-04-10
2024-03-27
No

Before updating GetWatchItemCommandas described at the end of this post in watch.c:

CLIPS> (get-watch-item all)
FALSE
CLIPS> (watch all)
CLIPS> (get-watch-item all)
FALSE

After:

CLIPS> (get-watch-item all)
FALSE
CLIPS> (watch all)
CLIPS> (get-watch-item all)
TRUE
CLIPS> (unwatch all)
CLIPS> (get-watch-item all)
FALSE
CLIPS> (watch all)
CLIPS> (get-watch-item all)
TRUE
CLIPS> (unwatch rules)
CLIPS> (get-watch-item all)
FALSE

Updated GetWatchItemCommand:

/*******************************************/
/* GetWatchItemCommand: H/L access routine */
/*   for the get-watch-item command.       */
/*******************************************/
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; }

   /*===================================================*/
   /* If the name of the watch item to set is all, then */
   /* return true if all watch items are set to true.   */
   /* Otherwise, false is returned.                     */
   /*===================================================*/

   argument = theValue.lexemeValue->contents;

   if (strcmp(argument,"all") == 0)
     {
   WatchItemRecord *wPtr;
      for (wPtr = WatchData(theEnv)->ListOfWatchItems; wPtr != NULL; wPtr = wPtr->next)
        {

         if (!(*(wPtr->flag)))
           {
                   returnValue->lexemeValue = FalseSymbol(theEnv);
                   return;
           }
        }
      returnValue->lexemeValue = TrueSymbol(theEnv);
      return;
     }

   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); }
  }

Discussion

  • Gary Riley

    Gary Riley - 2024-04-10
    • status: open --> closed
    • assigned_to: Gary Riley
     
  • Gary Riley

    Gary Riley - 2024-04-10

    Added fix to svn repository for both the CLIPS get-watch-item function and the corresponding C function GetWatchItem.