NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing TestStand variables with custom Attributes at runtime

Solved!
Go to solution

Hi everyone,

I've searched the community for a similar problem but I didn't find anything useful so far.

I defined a custom Attribute for each LabVIEW IO control contained in serialArray[0:4] and I'd like to use it at run-time in order to use only the resource with the attribute set as true and possibly modify the other ones.

The problem is that during the execution those Attributes do not exist.

 

As a matter of fact the expression FileGlobals.serialArray[0].HasAttributes returns False.

 

Right now I can only access the attributes when I access the FileGlobals default. 

 

I've attached some pictures for more details.

 

Thanks to anyone willing to help me getting to the solution!

 

Regards,

Dimitris

 

 

Download All
0 Kudos
Message 1 of 4
(2,974 Views)

You should create a simple example that illustrates your problem and post the code.

 

I cannot reproduce your problem. If I create an attribute in a FileGlobals, the property .HasAttribute returns true.

 

FileGlobals can only be accessed from the sequences within the same sequence file.

 

If you create the attribute at run time, it will not be present the next time you run.

Marc Dubois
0 Kudos
Message 2 of 4
(2,953 Views)

Hi Marc,

here's a demo sequence.

In Locals.visaResources[0..4] the first four elements have the attribute set as False whereas the fifth has it set on True.

 

Thanks for helping me!

 

Regards,

 

Dimitris

0 Kudos
Message 3 of 4
(2,931 Views)
Solution
Accepted by topic author __dmtrs__

When you iterate over the VisaResources array, you must look at the attributes of the array elements themselves. When using a For Each loop with a CurrentElement as the iteration variable, the value of the VisaResources element is transferred to CurrentElement but not its attributes. Assigning values to a different variable transfer the values but not the attributes. If you want to look at the attributes, you must look at the element themselves. If you use a For loop instead of a For Each loop and that for each iteration of the For loop, you look at the attributes of the element using an indexing variable, the attribute is present.

 

If you want to transfer a value when assigning the array element to a value, you should add another component to your container that would contain the property that you want to transfer.

Marc Dubois
Message 4 of 4
(2,916 Views)