02-27-2013 02:07 AM
Hello,
I can not understand the meaning of function Evaluate() in below sentence,and can not find the explanation in help files,could someone help me ?
Step.DataSource != "Step.Result.PassFail" ? Step.Result.PassFail = Evaluate(Step.DataSource) : False, Step.Result.PassFail ? "Passed" : "Failed"
Solved! Go to Solution.
02-27-2013 06:16 AM
Lets assume In this case step.datasource has a variable stored ex "locals.num"
The function Evaluate(Step.DataSource) does the following :
Get the variable name stored in step.datasource i.e. locals.num
Return the data stored in locals.num
02-28-2013 09:25 PM - edited 02-28-2013 09:26 PM
Thank you!
this expression means below,but I am not clear that the "false" means, means do nothing?
if(Step.DataSource != "Step.Result.PassFail" )
{
Step.Result.PassFail = Evaluate(Step.DataSource)
}
else
{
false
}
if(Step.Result.PassFail )
{
passed
}
else
{
failed
}
02-28-2013 09:47 PM
The step status i.e. step.result.passfail is set to either pass or fail by the expressions.
Slighty modified your steps :
if(Step.DataSource != "Step.Result.PassFail" )
{
Step.Result.PassFail = Evaluate(Step.DataSource)
}
else
{
Step.Result.PassFail = false
}
if(Step.Result.PassFail )
{
Step.Result.PassFail=passed
}
else
{
Step.Result.PassFail=failed
}
03-01-2013 02:01 AM
Sorry,I am still not clear.
as you said,if Step.DataSource == "Step.Result.PassFail" (the default value of pass/fail step), then Step.Result.PassFail = false, then Step.Result.PassFail=failed,then the step fail. it seems wrong, Step.Result.PassFail should be valued by the output parameter.
03-01-2013 02:55 AM - edited 03-01-2013 03:08 AM
Sorry to confuse you.
Hope the explanation helps.
Step.DataSource != "Step.Result.PassFail" ? Step.Result.PassFail = Evaluate(Step.DataSource) : False, Step.Result.PassFail ? "Passed" : "Failed"
if(Step.DataSource != "Step.Result.PassFail" ) // True if user has selected a different data source ( by default its step.result.passfail)
{
Step.Result.PassFail = Evaluate(Step.DataSource) // Get variable stored in step.datasource.Read the value and store in step.result.passfail
}
else
{
false // Dont do anything when default data source is present
}
if(Step.Result.PassFail ) // It will have the latest value either by default or even if data source is changed.
{
passed //status is set as passed
}
else
{
failed //status is set as Failed
}
03-03-2013 11:00 PM
Thank you,now I'm clear.
03-04-2013 09:52 AM
As an added point of reference, we use the "Evaluate()" function to to parse Variables in a Step Name for TestStand steps. This makes our steps very readable and FAST to code in TestStand.
For example our tests to communicate to a device might be to write a value to a value to a specific parameter, such as writing a Setpoint Value. So the TestStand step name would look like:
[] Write:Setpoint(1)=200
Where Setpoint is the Parameter Name, (1) represents the Instance, and 200 is the value written
However we use the Evaluate() function to parse out variables:
Locals.sParameter = "Setpoint"
Locals.nInstance = 1
Parameters.nValue = 200
[]Write:{L.sParameter}({L.nInstance})={P.nValue}
(We use a shortened version of L. for Locals., P. for Parameters., etc. because it doesn't take up so much space on the Step Name)
We have a library subsequence (Check for Curly Brackets to be parsed) that parses out any variables that are enclosed in the {} curly brackets.
Replace "L." with "Locals.", etc. and then parse out the variables in the Pre-Expression,
and then EVALUATE the variables in the Post-Expression:
Locals.sTemporary ="RunState.Caller.RunState.Caller."& Locals.sVariable,
'If the variable exists, resolve it, if not replace it with '{ERROR}' and continue.
Locals.sTemporary =( PropertyExists(Locals.sTemporary)? Evaluate(Locals.sTemporary) :"{ERROR}"),
'Put the resolved variable (or error) back in place of its name
Locals.sWorkingString = Locals.sBeforeVar & Locals.sTemporary & Locals.sAfterVar
Also, during runtime, if there happens to be an error in the StepName, we can edit it and continue on using a "Set Step Name" tool.
Mike