NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Get an unknown dimension array from a sub sequence

Solved!
Go to solution
Highlighted

Hello,

 

I'm filling an array in a subsequence with an unknown quantity of datas (list of defects).

I update the upper bound of this array each time the operator want to add a new defect.

 

My issue is that I don't succeed to get this array from the main sequence because I don't know how many elements there are in my array.

 

Is there a trick to do this ?

 

(I'm sorry, but i'm not able to share my teststand sequence because of the internal policy of my company)

 

Thanks a lot in advance,

 

Jonathan

0 Kudos
Message 1 of 8
(266 Views)
Highlighted

Hello Jonathan,

 

If I understand correctly your question, than the answer is below:

 

Locals.A - the array of elements where you want to increment the size.

Locals.NumberOfElements - just a variable where we store the current size, we increase it and than set it back to Locals.A.

Se code below

 

Locals.NumberOfElements = Locals.A.GetNumElements(),
Locals.NumberOfElements++,
Locals.A.SetNumElements(Locals.NumberOfElements)

0 Kudos
Message 2 of 8
(248 Views)

Thanks for your reply, but I think you misunterstanded my question :

 

I know how to adjust the size of my array inside the sub sequence, but how can I get this array from the main sequence without knowing in advance how many elements there are?

0 Kudos
Message 3 of 8
(239 Views)
Highlighted

Where do you want to get it?

You said you want to get it from main sequence, where to?

0 Kudos
Message 4 of 8
(236 Views)
Highlighted

GetArray.PNG

 

Here is an exemple of what I want to do :

- In the subsequence, I have an empty array that I'm filling with the quantity of defects the operator found

- In the mainSequence, I want to get back the array to analyze and report it. But I can't set an array because I don't know in advance how many elements there will be in my subSequence "Array" parameter

 

I hope to be clear enough

0 Kudos
Message 5 of 8
(227 Views)
Highlighted
Solution
Accepted by topic author JonathanFrem

If you pass the parameter by reference (and you do according to the screenshot), you don't need to worry to match the size of the array.

The Subsequence will modify automatically the size of the input array.

 

I have just tested with a simple sequence where I am passing an empty array of strings, in the SubSequence I get the current size and increase it by one.

Calling multiple times the same subsequence, I see my original array (empty created) increased in size.

See the screenshot below.

 

TSUser_0-1600257476953.png

 

0 Kudos
Message 6 of 8
(220 Views)
Highlighted

Oh, I feel ashamed, I would have sworn that we MUST match parameters type/dimensions.

 

Thanks a lot, and sorry for this uninteresting question.

0 Kudos
Message 7 of 8
(216 Views)
Highlighted

No worries 😉 Glad that I could help!

 

You can help other users on the forum so that we keep paying it forward 🙂

 

Cheers,

Just a TSUser

0 Kudos
Message 8 of 8
(208 Views)