globle intBool EqFunction( void *theEnv, EXEC_STATUS) { DATA_OBJECT item, nextItem; int numArgs, i; struct expr *theExpression; /*====================================*/ /* Determine the number of arguments. */ /*====================================*/ numArgs = EnvRtnArgCount(theEnv,execStatus); if (numArgs == 0) return(FALSE); /*==============================================*/ /* Get the value of the first argument against */ /* which subsequent arguments will be compared. */ /*==============================================*/ theExpression = GetFirstArgument(); EvaluateExpression(theEnv,execStatus,theExpression,&item); /*=====================================*/ /* Compare all arguments to the first. */ /* If any are the same, return FALSE. */ /*=====================================*/ theExpression = GetNextArgument(theExpression); for (i = 2 ; i <= numArgs ; i++) { EvaluateExpression(theEnv,execStatus,theExpression,&nextItem); if (GetType(nextItem) != GetType(item)) { return(FALSE); } if (GetType(nextItem) == MULTIFIELD) { if (MultifieldDOsEqual(&nextItem,&item) == FALSE) { return(FALSE); } } else if (nextItem.value != item.value) { return(FALSE); } theExpression = GetNextArgument(theExpression); } /*=====================================*/ /* All of the arguments were different */ /* from the first. Return TRUE. */ /*=====================================*/ return(TRUE); }
globle intBool NeqFunction( void *theEnv) { DATA_OBJECT item, nextItem; int numArgs, i; struct expr *theExpression; /*====================================*/ /* Determine the number of arguments. */ /*====================================*/ numArgs = EnvRtnArgCount(theEnv); if (numArgs == 0) return(FALSE); /*==============================================*/ /* Get the value of the first argument against */ /* which subsequent arguments will be compared. */ /*==============================================*/ theExpression = GetFirstArgument(); EvaluateExpression(theEnv,theExpression,&item); /*=====================================*/ /* Compare all arguments to the first. */ /* If any are different, return FALSE. */ /*=====================================*/ for (i = 2, theExpression = GetNextArgument(theExpression); i <= numArgs; i++, theExpression = GetNextArgument(theExpression)) { EvaluateExpression(theEnv,theExpression,&nextItem); if (GetType(nextItem) != GetType(item)) { continue; } else if (nextItem.type == MULTIFIELD) { if (MultifieldDOsEqual(&nextItem,&item) == TRUE) { return(FALSE); } } else if (nextItem.value == item.value) { return(FALSE); } } /*=====================================*/ /* All of the arguments were identical */ /* to the first. Return TRUE. */ /*=====================================*/ return(TRUE); }
globle BOOLEAN DOsEqual( DATA_OBJECT_PTR dobj1, DATA_OBJECT_PTR dobj2) { if (GetpType(dobj1) != GetpType(dobj2)) { return(FALSE); } if (GetpType(dobj1) == MULTIFIELD) { if (MultifieldDOsEqual(dobj1,dobj2) == FALSE) { return(FALSE); } } else if (GetpValue(dobj1) != GetpValue(dobj2)) { return(FALSE); } return(TRUE); }
globle void SwitchFunction( void *theEnv, DATA_OBJECT_PTR result) { DATA_OBJECT switch_val,case_val; EXPRESSION *theExp; result->type = SYMBOL; result->value = EnvFalseSymbol(theEnv); /* ========================== Get the value to switch on ========================== */ EvaluateExpression(theEnv,GetFirstArgument(),&switch_val); if (EvaluationData(theEnv)->EvaluationError) return; for (theExp = GetFirstArgument()->nextArg ; theExp != NULL ; theExp = theExp->nextArg->nextArg) { /* ================================================= RVOID is the default case (if any) for the switch ================================================= */ if (theExp->type == RVOID) { EvaluateExpression(theEnv,theExp->nextArg,result); return; } /* ==================================================== If the case matches, evaluate the actions and return ==================================================== */ EvaluateExpression(theEnv,theExp,&case_val); if (EvaluationData(theEnv)->EvaluationError) return; if (switch_val.type == case_val.type) { if ((case_val.type == MULTIFIELD) ? MultifieldDOsEqual(&switch_val,&case_val) : (switch_val.value == case_val.value)) { EvaluateExpression(theEnv,theExp->nextArg,result); return; } } } }