NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create preexpression depending on an array size

Solved!
Go to solution

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

0 Kudos
Message 1 of 3
(2,253 Views)

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

0 Kudos
Message 2 of 3
(2,237 Views)
Solution
Accepted by topic author OnlyOne

(GetNumElements(FileGlobals.MyArray) == 7)

?

(Step.Result.Numeric = FileGlobals.MyArray[6])

:

(Step.Result.Numeric = 0)

Regards
Ray Farmer
0 Kudos
Message 3 of 3
(2,234 Views)