Code to Evaluate Groups of Expressions

If a group of expressions is to be evaluated against the same context, it is more efficient to create a stored evaluation context rather than iterating the expressions through the Eval method, which creates and destroys an evaluation context for each expression evaluated.

  1. Using the ExpressionEval object, oExpressionEval, created in Code to Connect to the Expression Store, create a stored evaluation context using the dictProfiles context created in Code to Create an Evaluation Context.

    Dim oEvaluationContext
    Set oEvaluationContext = _
     oExpressionEval.CreateEvalContext(dictProfiles)
    
  2. Load all the expressions in the Expression Store into the Expression Cache, including the expression created in Code to Create a New Expression. This step is optional. Any expressions not preloaded will be loaded by the EvalInContext method when those expressions are evaluated. If you do not want to load all the expressions, you can load individual expressions using the LoadExpr method.

    oExpressionEval.LoadAll
    
  3. The expression ID, lExpressionID, for the expression created in Code to Create a New Expression was retrieved in Code to Manipulate Expressions. Evaluate this expression against the evaluation context.

    Dim vResult
    vResult = oExpressionEval.EvalInContext(lExpressionID, _
     oEvaluationContext)
    

The result of evaluating the expression, vResult, is True.

  1. Evaluate any other expressions using the same stored context, and then release the context.

    Set oEvaluationContext = Nothing
    


All rights reserved.