NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find a certain number in a teststand array variable?

Hello,

The problem is quite simple. I'd like to make a precondition for a step, that is 'True' if a certain number is found in a TestStand array variable. Consider, for example, I have 1D array of size 100 (see below), containing integers in random order.

Case1: 4 exists = True
Case 2: 7 exists = False

Parameters.Array_of_numbers:

Index  Nr
0        2
1        3
2        4
3        6
4        9
5        8
.        .
.        .
.        .
99     .

Is there a straightforward way to do this in TS (expression)?  Of course, I could make a loop around the desired step where every index is checked one by one, but I'm looking for simpler solution.

Thanks beforehand!

 
0 Kudos
Message 1 of 5
(4,190 Views)

Hi,

The simplest way would be to make the size of the array equal to the number that exist,

eg Case 1, your array size would be 4 and Case 2 the size would be 7.

Then you can use the function to determine the size of the array.

How is your array derived?

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 2 of 5
(4,183 Views)
Hi,

The application is a "test-to-order" type application. I have a certain test mix containing numeruous tests and the testing strategies are chosen among them. This array in question contains actulally the chosen testing strategy, and want to control the flow accordingly. For needed flexibility, I would not like to fix one test to certain array index. My testing mix will grow and also there will be new strategies.

Testing mix:

0=Test 1
1=Test 2
2=Test 3
3=Test 4
...

Testing strategy 1=1,3,6...
Testing strategy 2=0,8,12...
...

0 Kudos
Message 3 of 5
(4,182 Views)
One idea:

Make it an array of containers instead of an array of numbers. That way the elements can be named. Named elements can be indexed by name.

array["test 1"]
array["test 2"]

Then your precondition could just be:

PropertyExists("Locals.array[\"test 0\"]")

NOTE: The interior " characters need to be escaped with a backslash as shown above.

You could even then attach subproperties to your elements if you need more data stored. For example:

array["test 1"].data
array["test 1"].options
etc.

Hope this helps,
-Doug

Message 4 of 5
(4,167 Views)
* * Thanks dug! * *

This was a prompt solution and works fine.  Instead of numbers, my testing strategy array now contains actually true step names as properties. So, the full path from order->test to order->database is quite clear to understand.

I certainly will also consider your hint about storing other information as subproperties.
0 Kudos
Message 5 of 5
(4,157 Views)