05-02-2019 04:21 AM
Hello,
i have a none adapter teststep that has a prexpression like: Step.Result.Numeric = FileGlobals.MyArray[6]
When running the testplan and the array has not this size then testplan pops up an exception.
My question is: How can i change the preexpression that this happens:
if (GetNumElements(FileGlobals.MyArray) == 7)
{
Step.Result.Numeric = FileGlobals.MyArray[6]
}
else
{
Step.Result.Numeric = 0
}
Thanks
Solved! Go to Solution.
05-02-2019 05:18 AM
Hi OnlyOne,
You can use the conditional operator to achieve what you want in a pre-expression, eg.
Step.Result.Numeric = (GetNumElements(FileGlobals.MyArray) == 7) ? FileGlobals.MyArray[6] : 0
I hope this helps,
Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)
Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor
05-02-2019 05:21 AM
(GetNumElements(FileGlobals.MyArray) == 7)
?
(Step.Result.Numeric = FileGlobals.MyArray[6])
:
(Step.Result.Numeric = 0)