ExpressionEval.Eval

Ee823995.c++_on(en-US,CS.10).gifEe823995.vb_off(en-US,CS.10).gif

Use this method to evaluate an expression.

Definition

Function Eval(nExprID As Long,pDictObjs As Object) As Variant

Parameters

nExprID

[in] A Long that contains the unique identifier for the expression in the expression store.

pDictObjs

[in] A Dictionary object that contains a set of profiles.

Return Values

This method returns a Variant indicating the result of evaluating the expression in the specified context. The result may be True, False, or Nothing. Nothing indicates the expression could not be evaluated.

Error Values

This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to either standard or custom COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM errors, and the standard COM errors with special meanings, that this method can return.

Constant Value Description
E_EXPR_BADCONNECTION &H8110001F Invalid connection
E_EXPR_BADEXPRID &H8110000A Invalid expression ID specified
E_EXPR_NOCONNECTIONSTRING &H8110000D No connection string specified
E_EXPR_NOTFOUND &H81100012 Could not find the specified expression ID, nExprID, in the expression store

Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

Expressions must be pre-compiled and loaded into the expression cache before being evaluated. The Eval method first checks the expression cache for the expression, and if not found, loads the expression from the expression store. Use the LoadExpr or LoadAll method to preload an expression into the expression cache and improve evaluation performance.

An expression is evaluated against data contained in a set of profiles. This set of profiles is referred to as an evaluation context. A new evaluation context is generated by the Eval method using the Dictionary object. The Eval method discards the new context after completing the evaluation. This process is not efficient if many expressions must be evaluated against the same context.

If an evaluation context will be used across multiple expressions, create a context in the context cache using the CreateEvalContext method. Use the EvalInContext method to evaluate expressions in this new common context.

The Connect method must be called before using the Eval method.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

Example

' dictUser1, dictAddress1, & dictProfiles are Dictionary objects
' create 2 profiles

dictUser1.firstName = "Joe"
dictUser1.lastName = "User"
dictAddress1.city = "Somewhere"
dictAddress1.state = "WA"

' add the profiles to the context Dictionary

dictProfiles.User = dictUser1
dictProfiles.Address = dictAddress1

' evaluate the expression, vResult is a Variant

vResult = oExpressionEval.Eval(2134, dictProfiles)

See Also

ExpressionEval Object

ExpressionEval.Connect

ExpressionEval.CreateEvalContext

ExpressionEval.EvalInContext

ExpressionEval.LoadExpr


All rights reserved.