void SDCCommand( Environment *theEnv, UDFContext *context, UDFValue *returnValue) { UDFValue theArg; returnValue->lexemeValue = CreateBoolean(theEnv,GetDynamicConstraintChecking(theEnv)); if (! UDFFirstArgument(context,ANY_TYPE_BITS,&theArg)) { return; } SetDynamicConstraintChecking(theEnv,theArg.value != FalseSymbol(theEnv)); }
BOOL FAR PASCAL ExecDlg ( HWND hDlg, unsigned message, WORD wParam, LONG lParam) { switch (message) { case WM_INITDIALOG: { WPARAM item; SetWindowText ( hDlg, (LPSTR)"Execution Options" ); /*-----------------------------+ | Initalize Strategy Combo Box | +-----------------------------*/ #if CONFLICT_RESOLUTION_STRATEGIES SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_ADDSTRING,0,(LPARAM)((LPSTR) "Depth")); SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_ADDSTRING,0,(LPARAM)((LPSTR) "Breadth")); SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_ADDSTRING,0,(LPARAM)((LPSTR) "LEX")); SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_ADDSTRING,0,(LPARAM)((LPSTR) "MEA")); SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_ADDSTRING,0,(LPARAM)((LPSTR) "Complexity")); SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_ADDSTRING,0,(LPARAM)((LPSTR) "Simplicity")); SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_ADDSTRING,0,(LPARAM)((LPSTR) "Random")); switch ( GetStrategy()) { case DEPTH_STRATEGY: item = (int) SendDlgItemMessage(hDlg,IDC_EXE_STRATEGY,CB_FINDSTRING,0,(LPARAM)((LPSTR)"Depth")); break; case BREADTH_STRATEGY: item = (int) SendDlgItemMessage(hDlg,IDC_EXE_STRATEGY,CB_FINDSTRING,0,(LPARAM)((LPSTR)"Breadth")); break; case LEX_STRATEGY: item = (int) SendDlgItemMessage(hDlg,IDC_EXE_STRATEGY,CB_FINDSTRING,0,(LPARAM)((LPSTR)"LEX")); break; case MEA_STRATEGY: item = (int) SendDlgItemMessage(hDlg,IDC_EXE_STRATEGY,CB_FINDSTRING,0,(LPARAM)((LPSTR)"MEA")); break; case COMPLEXITY_STRATEGY: item = (int) SendDlgItemMessage(hDlg,IDC_EXE_STRATEGY,CB_FINDSTRING,0,(LPARAM)((LPSTR)"Complexity")); break; case SIMPLICITY_STRATEGY: item = (int) SendDlgItemMessage(hDlg,IDC_EXE_STRATEGY,CB_FINDSTRING,0,(LPARAM)((LPSTR)"Simplicity")); break; case RANDOM_STRATEGY: item = (int) SendDlgItemMessage(hDlg,IDC_EXE_STRATEGY,CB_FINDSTRING,0,(LPARAM)((LPSTR)"Random")); break; } #else SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_ADDSTRING,0,(LPARAM)((LPSTR) "Depth")); item = (int) SendDlgItemMessage(hDlg,IDC_EXE_STRATEGY,CB_FINDSTRING,0,(LPARAM)((LPSTR)"Depth")); #endif SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_SETCURSEL, item, 0); /*-----------------------------+ | Initalize Salience Combo Box | +-----------------------------*/ #if DYNAMIC_SALIENCE SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_ADDSTRING,0,(LPARAM)((LPSTR) "When Defined")); SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_ADDSTRING,0,(LPARAM)((LPSTR) "When Activated")); SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_ADDSTRING,0,(LPARAM)((LPSTR) "Every Cycle")); switch (GetSalienceEvaluation()) { case WHEN_DEFINED: item = (int) SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_FINDSTRING,0,(LPARAM)((LPSTR) "When Defined")); break; case WHEN_ACTIVATED: item = (int) SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_FINDSTRING,0,(LPARAM)((LPSTR) "When Activated")); break; case EVERY_CYCLE: item = (int) SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_FINDSTRING,0,(LPARAM)((LPSTR) "Every Cycle")); break; } #else SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_ADDSTRING,0,(LPARAM)((LPSTR) "When Defined")); item = SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_FINDSTRING,0,(LPARAM)((LPSTR) "When Defined")); #endif SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_SETCURSEL, item, 0); /*-----------------------------------+ | Disable Incremental reset check box | | if any rules are in the system. | +------------------------------------*/ if ( GetNextDefrule (NULL) != NULL ) { EnableWindow(GetDlgItem(hDlg, IDC_WATCH_ALL ), TRUE); } /*----------------------------+ | Initalize Other Check Boxes | +----------------------------*/ SetCheckBox(hDlg, IDC_EXE_STATIC, GetStaticConstraintChecking()); SetCheckBox(hDlg, IDC_EXE_DYNAMIC, GetDynamicConstraintChecking()); SetCheckBox(hDlg, IDC_EXE_AUTO, GetAutoFloatDividend()); #if DEFGLOBAL_CONSTRUCT SetCheckBox(hDlg, IDC_EXE_GLOBAL, GetResetGlobals()); #endif #if DEFTEMPLATE_CONSTRUCT SetCheckBox(hDlg, IDC_EXE_FACT, GetFactDuplication()); #endif #if INCREMENTAL_RESET & (! RUN_TIME) SetCheckBox(hDlg, IDC_EXE_RESET, GetIncrementalReset()); #endif #if (!RUN_TIME) SetCheckBox(hDlg, IDC_EXE_SEQUENCE, GetSequenceOperatorRecognition()); #endif return (TRUE); } case WM_COMMAND: { switch ( wParam ) { case IDC_OK: { int value; char Msg[40]; #if DYNAMIC_SALIENCE /*--------------------------+ | Decode Salience Combo Box | +--------------------------*/ value = (int) SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_GETCURSEL, 0, 0); SendDlgItemMessage (hDlg, IDC_EXE_SALIENCE, CB_GETLBTEXT, value, (LONG)Msg ); if ( strcmp (Msg, "When Defined" ) == 0 ) SetSalienceEvaluation(WHEN_DEFINED); else if (strcmp(Msg, "When Activated" ) == 0) SetSalienceEvaluation(WHEN_ACTIVATED); else SetSalienceEvaluation(EVERY_CYCLE); #endif #if CONFLICT_RESOLUTION_STRATEGIES /*--------------------------+ | Decode Strategy Combo Box | +--------------------------*/ value = (int) SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_GETCURSEL, 0, 0); SendDlgItemMessage (hDlg, IDC_EXE_STRATEGY, CB_GETLBTEXT, value, (LONG)Msg ); if ( strcmp (Msg, "Depth" ) == 0 ) SetStrategy(DEPTH_STRATEGY); else if (strcmp(Msg, "Breadth" ) == 0) SetStrategy(BREADTH_STRATEGY); else if (strcmp(Msg, "LEX") == 0 ) SetStrategy(LEX_STRATEGY); else if (strcmp(Msg, "MEA") == 0 ) SetStrategy(MEA_STRATEGY); else if (strcmp(Msg, "Complexity") == 0 ) SetStrategy(COMPLEXITY_STRATEGY); else if (strcmp(Msg, "Simplicity") == 0 ) SetStrategy(SIMPLICITY_STRATEGY); else SetStrategy(RANDOM_STRATEGY); #endif /*-------------------------+ | Decode Other Check Boxes | +-------------------------*/ SetStaticConstraintChecking ( IsDlgButtonChecked(hDlg, IDC_EXE_STATIC)); SetDynamicConstraintChecking ( IsDlgButtonChecked(hDlg, IDC_EXE_DYNAMIC)); SetAutoFloatDividend ( IsDlgButtonChecked(hDlg, IDC_EXE_AUTO)); #if DEFGLOBAL_CONSTRUCT SetResetGlobals ( IsDlgButtonChecked(hDlg, IDC_EXE_GLOBAL)); #endif #if DEFTEMPLATE_CONSTRUCT SetFactDuplication( IsDlgButtonChecked(hDlg, IDC_EXE_FACT)); #endif #if INCREMENTAL_RESET & (! RUN_TIME ) SetIncrementalReset ( IsDlgButtonChecked(hDlg, IDC_EXE_RESET)); #endif #if ( ! RUN_TIME ) SetSequenceOperatorRecognition ( IsDlgButtonChecked(hDlg, IDC_EXE_SEQUENCE)); #endif } case IDC_CANCEL: { EndDialog( hDlg, IDOK); return (TRUE); } /*-------------------+ | Toggle Check Boxes | +-------------------*/ case IDC_EXE_RESET: case IDC_EXE_STATIC: case IDC_EXE_DYNAMIC: case IDC_EXE_GLOBAL: case IDC_EXE_FACT: case IDC_EXE_AUTO: case IDC_EXE_SEQUENCE: { SetCheckBox ( hDlg, wParam, !IsDlgButtonChecked (hDlg, wParam)); return (TRUE); } } } } return (FALSE); }
/******************************************************************** NAME : EvaluateSlotDefaultValue DESCRIPTION : Checks the default value against the slot constraints and evaluates static default values INPUTS : 1) The slot descriptor 2) The bitmap marking which facets were specified in the original slot definition RETURNS : True if all OK, false otherwise SIDE EFFECTS : Static default value expressions deleted and replaced with data object evaluation NOTES : On errors, slot is marked as dynamix so that DeleteSlots() will erase the slot expression ********************************************************************/ static bool EvaluateSlotDefaultValue( Environment *theEnv, SlotDescriptor *sd, const char *specbits) { UDFValue temp; bool oldce,olddcc, vPass; ConstraintViolationType vCode; /* =================================================================== Slot default value expression is marked as dynamic until now so that DeleteSlots() would erase in the event of an error. The delay was so that the evaluation of a static default value could be delayed until all the constraints were parsed. =================================================================== */ if (! TestBitMap(specbits,DEFAULT_DYNAMIC_BIT)) sd->dynamicDefault = 0; if (sd->noDefault) return true; if (sd->dynamicDefault == 0) { if (TestBitMap(specbits,DEFAULT_BIT)) { oldce = ExecutingConstruct(theEnv); SetExecutingConstruct(theEnv,true); olddcc = SetDynamicConstraintChecking(theEnv,true); vPass = EvaluateAndStoreInDataObject(theEnv,sd->multiple, (Expression *) sd->defaultValue,&temp,true); if (vPass != false) vPass = (ValidSlotValue(theEnv,&temp,sd,NULL,"the 'default' facet") == PSE_NO_ERROR); SetDynamicConstraintChecking(theEnv,olddcc); SetExecutingConstruct(theEnv,oldce); if (vPass) { ExpressionDeinstall(theEnv,(Expression *) sd->defaultValue); ReturnPackedExpression(theEnv,(Expression *) sd->defaultValue); sd->defaultValue = get_struct(theEnv,udfValue); GenCopyMemory(UDFValue,1,sd->defaultValue,&temp); RetainUDFV(theEnv,(UDFValue *) sd->defaultValue); } else { sd->dynamicDefault = 1; return false; } } else if (sd->defaultSpecified == 0) { sd->defaultValue = get_struct(theEnv,udfValue); DeriveDefaultFromConstraints(theEnv,sd->constraint, (UDFValue *) sd->defaultValue,sd->multiple,true); RetainUDFV(theEnv,(UDFValue *) sd->defaultValue); } } else { vCode = ConstraintCheckExpressionChain(theEnv,(Expression *) sd->defaultValue,sd->constraint); if (vCode != NO_VIOLATION) { PrintErrorID(theEnv,"CSTRNCHK",1,false); WriteString(theEnv,STDERR,"Expression for "); PrintSlot(theEnv,STDERR,sd,NULL,"dynamic default value"); ConstraintViolationErrorMessage(theEnv,NULL,NULL,0,0,NULL,0, vCode,sd->constraint,false); return false; } } return true; }