10-26-2010 01:38 PM
When I insert a Test step, in the the default data source field is Step.Result.[Numeric, String, Pass/Fail, etc.]. I am accessing this expression by calling "RunState.CallingStep.datasource" which gives me whatever has been entered into this field. If the datasource field contains the variable "Step.Result.Numeric" for example, then when i access the datasource expression, the string "Step.Result.Numeric" is outputted instead of the value located at this location.
I would like to access the value of variable located in the Data Source expression.
10-26-2010 02:46 PM
Since DataSource is actually an Expression, you need to call Evaluate on it, e.g. Locals.foo = Evaluate(Step.Result.DataSource)
10-26-2010 02:57 PM
I tried to use Evaluate(RunState.CallingStep.DataSource) but i get an error. Error is -17308; Specified value does not have the expected type. Because Evaluate is expecting a string type.
10-26-2010 03:06 PM
Oops, you have to wrap Expression datatypes in the Str() function. Your final call would be Evaluate(Str(RunState.CallingStep.DataSource)).
10-26-2010 03:14 PM
i tried that and it didnt work
10-26-2010 03:24 PM - edited 10-26-2010 03:26 PM
Keep in mind that if the DataSource is something like "Step.Result.PassFail" that the expression will be evaluated with the current step being the Step object, not your calling step. You're changing the context of the expression without changing the expression to account for it.
A quick fix would be to replace "Step." with "RunState.CallingStep" but that may break other expressions unexpectedly.
10-27-2010 01:02 AM
Hi DL,
Why are you doing this and where are you doing this. Maybe a simple example may help to understand your problem better.
10-27-2010 09:51 AM
Locals.mystring = Str(Evaluate(Step.DataSource))
But not sure why you want to do this. There might be a better way to accomplish what you are trying to do. If you post more details perhaps someone can suggest something.
Hope this helps,
-Doug
10-27-2010 01:35 PM
I'm making an Engine Callback for SequenceFilePostStepFailure. In this callback, i'm creating a custom popup error message box. In this error message box, i want to display the calling step's name, the calling step's measured value (which caused the error to occur), and the calling step's minimum and maximum limit values.
In the test step, there is an expression field for DataSource. However, in order to make this error pop up box applicable to all scripts, and not rewrite how the DataSource expression is stated, i want to capture the Datasource expression and evaluate it.
For example,
If the DataSource expression is: Step.Result.Numeric
I want to be able to query the Step.Result.Numeric expression and pull that value to display in the error pop up box. The reason for this is that if there is a different statement in the DataSource expression such as: Step.Result.Number*10, I want the error pop up box to pull the value of that expression.
If i call RunState.CallingStep.DataSource, then the correct expression is displayed in the error pop up box. However, i would like the value of that expression displayed and not the string expression itself.
10-27-2010 02:21 PM
Here is my message expression for a numeric limit test.
"Step Failed: " + RunState.CallingStep.Name + "\n" +
"Minimum Value: " + RunState.CallingStep.Limits.LowExpr + "\n" +
"Maximum Value: " + RunState.CallingStep.Limits.HighExpr + "\n" +
"Measured Value: " + RunState.CallingStep.DataSource + "\n\n" +
"Failure Date: " + Str(Date()) + "\n" +
"Failure Time: " + Str(Time())
I would like to evaluate the expressions contained in the red highlighted text.