NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Access elements of an array passed as Object Reference

Solved!
Go to solution

Hi to all!

I'm quite new to TestStand and so my question could be quite simple but I was not able to find solution looking at previous messages.

 

I have a sequence which passes one array (of custom data type) to another one to do basic stuff on the array (reverse the order of the elements for example).

I want to pass to the called sequence an Object Reference of the array

 

The problem is that I'm not able to read the element of array inside the called sequence using the object reference.

I found the way get the number of elements but I not able to access the element 😞

 

Moreover the GUI of TestStand is able to let me see the array pointed by the object reference which is passed inside the called sequence, therefore it is possible to access... but how ???

 

I want to do the operations on passed Object Reference inside a TestStand "Statement step" if it is possible.

 

Thank you so much.

Andrea

 

In other words:

How to access the field "temperatureTag" of the element number "0" starting from referenceToClone Object Reference variable ? 

 

Locals.referenceToClone[0].temperatureTag does not work...

 

 

testStandQuestion.jpg 

 

 

 

 

 

0 Kudos
Message 1 of 16
(8,751 Views)

Use (*Locals.referenceToClone)[0].temperatureTag  to get the required property.

 

You can use the dereference operator as specified in http://zone.ni.com/reference/en-XX/help/370052K-01/tsfundamentals/infotopics/operators_expression/ to get the property from object reference.

 

- Shashidhar

Message 2 of 16
(8,728 Views)

Thank you for the reply!

 

The problem is that I'm implementing my sequence with TestStand 4.2 and the use of "*" does not work! 😞

http://zone.ni.com/reference/en-XX/help/370052H-01/tssuppref/infotopics/operators_expression/

 

... The new question is:

"How to dereference an Object Reference in TestStand 4.2 ?"

0 Kudos
Message 3 of 16
(8,698 Views)
Solution
Accepted by topic author andrea.venturi

I am not sure what is the recommended way to solve your problem. When trying few alternatives, I was able to get the required value with following expression (Tested with TestStand 2014):

Locals.referenceToClone.GetPropertyObject("[0]", 0).temperatureTag

 

 

Try and let me know if it works for you.

Use this workaround with caution.

 

- Shashidhar

0 Kudos
Message 4 of 16
(8,681 Views)

Sorry for my late reply!

 

YES !!! It works perfectly!

Thank you very much!

0 Kudos
Message 5 of 16
(8,583 Views)

how do you get to expand that view to see the properties ?

i can't do that when getting my object reference (array of objects with 2 properties)

 

0 Kudos
Message 6 of 16
(7,464 Views)

Hi

 

Hi there is no way to expand, because this comes from .Net not TestStand.

To see the members you have to use your src or the .net object brower.

 

to work on with that reference you have to use the net step type and access the objects in that array.

 

Regards

 

Juergen

 

 

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 7 of 16
(7,432 Views)

Hi Juergen

 

I have attached a stripped down version of my seq. (only one step left).

The object reference i receive is to an array of objects containing 2 properties (meas1(double) &  meas2(double)).

 

How do i work on with that data in the next step. Is it possible you could create such a step in the attached seq., or would that require more information ?

 

br

Nikolaj

0 Kudos
Message 8 of 16
(7,388 Views)

Hi,

 

Which version of TS are you using?

 

Regards

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 9 of 16
(7,379 Views)

2014

0 Kudos
Message 10 of 16
(7,374 Views)