NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Read/write attributes of local variable of "Object Reference" type

How to access attributes of a local variable of "Object Reference" type?

 

Accessing attributes of a "simple" data type is easy an can be done by using the lookup string. "Locals.clusterData.Attributes.MyCompany.StringData". 

See https://www.ni.com/docs/en-US/bundle/teststand-api-reference/page/tsapiref/propertyobject-attributes... 

 

However when the local variable is of "Object Reference" type this does not work.

 

0 Kudos
Message 1 of 15
(3,177 Views)

Hi,

 

For me it worked the same way that it works when I access the fields of the ObjRef:

 Locals.objRef->field1

 Locals.objRef->field2

 

 thus,

 

 Locals.objRef->Attributes->attribute1

 Locals.objRef->Attributes->attribute2

 

 

0 Kudos
Message 2 of 15
(3,137 Views)

Hi israel

 

I can't make it work. Could you please modify my example and upload?

 

0 Kudos
Message 3 of 15
(3,112 Views)

I've figured it's possible to do like this: "Locals.GetPropertyObject("objData",0).Attributes.MyCompany.StringData".

In this case it's not possible to "browse" the attributes as if the local variable was not of "Object Reference" type.

Message 4 of 15
(3,108 Views)

Gladfully would,

But it seems that I can't open the file, because your version is newer than mine.

 

Can you please try saving it As a TS 2012-2013 format?

 

0 Kudos
Message 5 of 15
(3,107 Views)

Appreciate it. TestStand 2012 version attached. Thanks in advance.

0 Kudos
Message 6 of 15
(3,099 Views)

Hi, sorry for the delay...

A working file is attached.

0 Kudos
Message 7 of 15
(3,065 Views)

Hi israel

 

Thanks for the reply but it was not what I had in mind. The function should work on the "Locals.objData" attributes not on the "Locals.clusterData" attribute. This was only included as an example of what I would like to do.
I've attached the example again with the "Locals.clusterData" removed.

 

Thanks in advance.

0 Kudos
Message 8 of 15
(3,034 Views)

I get you now.

I thought you want to access the Local object's attributes using the Reference Object.

 

I tried several combinations but have come to a dead end, as for now I can't find a way accessing it, even though the TS lets you creating it.

But can I ask why you need the attributes on the reference rather than on the referred object itself?

0 Kudos
Message 9 of 15
(2,992 Views)

The attribute give information regarding the object passed but the information is not (at time being) a part of the object. Adding the attribute is/would be a way to avoid changing the original object as i do not know where it is used and by whom (is a part of a test framework).

It is possible to access the attribute like this "Locals.GetPropertyObject("objData",0).Attributes.MyCompany.StringData" but seems not to be the right way.

Thanks for spending your time helping me

0 Kudos
Message 10 of 15
(2,974 Views)