ExpressionEval.EvalInContext

Ee799160.c++_on(en-US,CS.10).gifEe799160.vb_off(en-US,CS.10).gif

Use this method to evaluate an expression against a pre-established context stored in the context cache.

Definition

Function EvalInContext(nExprID As Long,pContext As Object) As Variant

Parameters

nExprID

[in] A Long that contains the unique identification of the expression in the expression store.

pContext

[in] An ExprEvalContext object that identifies the specific context for this evaluation.

Return Values

This method returns a Variant indicating the results of evaluating the expression in the specified context. This 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_MISSINGPROP &H8110001D Invalid ExprEvalContext object
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

The Eval method creates and discards an evaluation context for every evaluation. Evaluating against a stored context optimizes performance when multiple expressions need to be evaluated in the same context. Create the context for evaluation using the CreateEvalContext method.

Expression results are also stored in the context cache. If the result of a particular expression is requested multiple times from the same ExprEvalContext object using the EvalInContext method, the result is retrieved from the cache rather than by re-evaluating the expression, further increasing efficiency.

Ee799160.caution(en-US,CS.10).gifCaution

  • The state of the profile objects that comprise the context should not be externally changed during the lifetime of the ExprEvalContext object; doing so leads to non-deterministic evaluation results.

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

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

Example

' oEvalContext is an ExprEvalContext object
' vResult is a Variant

vResult = oExpressionEval.Eval(2134, oEvalContext)

See Also

ExpressionEval Object

ExpressionEval.Connect

ExpressionEval.CreateEvalContext

ExpressionEval.Eval

ExpressionEval.LoadExpr


All rights reserved.