11-11-2010 09:13 AM
Hi,
I code in a process model callback and would like to evaluate an expression with the Runstate.Caller context.
I found the method
Expression.Evaluate ( evaluationContext, evaluationOptions = EvalOption_NoOptions)
This is exactly what I need. However, if I have a CallingStep.Expr, which is a expression, I can't access the Evaluate() function. It is not available, only the PropertyObjects functions are.
How can I cast it to be an Expression so I can access the function Evaluate?!
I though I could do:
Runstate.CallingStep.Expr.Evaluate(Runstate.Caller, 0x0)
This would return the expression evaluated in the caller context as a PropertyObject.
But it's not the case, I'm missing something so TS know Runstate.CallingStep.Expr is an Expression... even if I add it to Watch panel, it shows it's an expression...
Thank you.
Solved! Go to Solution.
11-11-2010 12:41 PM
11-11-2010 12:54 PM
Thanks, I didn't though of do it this way.
This is one way to achieve it, by doing something like:
Runstate.Caller.AsPropertyObject.EvaluateEx(RunState.CallingStep.TS.CustomResults[1].Name, 0x0).GetValString("", 0x0)
This retrieves the string representing the additionnal result[1] name of my step, which is an expression using local variable in the sequence.
Thanks j_dodek.
If anyone would like to also add a comment about using Expression.Evaluate() properly or an example, it would be appreciated.
11-12-2010 06:25 AM
Hi Mat,
Just for more understanding
you wrote: I'm missing something so TS know Runstate.CallingStep.Expr is an Expression
Is this your "Expression" a Statement step Type ?
Or is your "Expression" in every Step in Pre/Post/Status or other in stuff
Could you provide a screen shot that descripes what you are looking for.
I do not understand it.
Regards
Juergen
11-12-2010 08:17 AM - edited 11-12-2010 08:17 AM
I have an object of type Expression (from what I understand and from what the watch panel is showing) and I was expecting to be able to use the Evaluate() function.
Expression.Evaluate(seqContext, options)
But it seems that it's a propertyobject because only the function of this type are available.
I've attached a screenshot. Thank you.
11-12-2010 08:59 AM
The Expression type in the API is not the same as the Expression type of a PropertyObject. The Expression PropertyObject type really is just a "labeled" string that lets you know it's supposed to be an expression.
To create an API Expression Object, you need to call Engine.NewExpression.