04-01-2020
09:37 AM
- last edited on
11-01-2024
05:28 PM
by
Content Cleaner
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".
However when the local variable is of "Object Reference" type this does not work.
04-01-2020 12:35 PM
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
04-02-2020 08:44 AM
Hi israel
I can't make it work. Could you please modify my example and upload?
04-02-2020 09:59 AM
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.
04-02-2020 10:05 AM - edited 04-02-2020 10:05 AM
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?
04-02-2020 11:28 AM
Appreciate it. TestStand 2012 version attached. Thanks in advance.
04-05-2020 04:23 PM
Hi, sorry for the delay...
A working file is attached.
04-08-2020 01:22 AM
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.
04-13-2020 12:23 PM
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?
04-15-2020 10:30 AM
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