IExpressionEval::Eval

Ee823994.c++_off(en-US,CS.10).gifEe823994.vb_on(en-US,CS.10).gif

Use this method to evaluate an expression.

Definition

HRESULT IExpressionEval::Eval(longnExprID,IDictionary*pDictObjs,VARIANT* pvResult);

Parameters

nExprID

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

pDictObjs

[in] A pointer to the IDictionary interface of a Dictionary object that contains a set of profiles.

pvResult

[out, retval] A pointer to a VARIANT indicating the result of evaluating the expression in the given context.

Return Values

This method returns an HRESULT indicating whether the method completed successfully. See the Error Values section for more details. The result of evaluating the expression is contained in the pvResult parameter. The result may be TRUE, FALSE, or NULL. NULL indicates the expression could not be evaluated.

Error Values

This method returns S_OK (0x00000000) to indicate success and either standard or custom COM HRESULT 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 0x8110001F Invalid connection
E_EXPR_BADEXPRID 0x8110000A Invalid expression ID specified
E_EXPR_NOCONNECTIONSTRING 0x8110000D No connection string specified
E_EXPR_NOTFOUND 0x81100012 Could not find the specified expression ID, nExprID, in the expression store

Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return 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.

The pvResult parameter contains valid data only if the method completes successfully.

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

See Also

ExpressionEval Object

IExpressionEval::Connect

IExpressionEval::CreateEvalContext

IExpressionEval::EvalInContext

IExpressionEval::LoadExpr


All rights reserved.