NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use SetNthSubPropertyName correctly?

Hi, I want to use API function to add or change the Name or key of the array, e.g. I have an array of container, called DataTest

cxia_0-1631780415448.png

 

Now I want to add a Name to each element, namely 

 

cxia_1-1631780522332.png

 

I have found the API function called SetNthSubPropertyName, which can be used

to dynamically set the Name (either in Teststand or external programming language).

However, I use the following script, it leads to error

FileGlobals.DataTest.SetNthSubPropertyName("", 0, 0, "SomeName0"),
FileGlobals.DataTest.SetNthSubPropertyName("", 1, 0, "SomeName1"),

Interestingly, I can use similar code to change the sub fields, e.g. 

FileGlobals.DataTest[0].SetNthSubPropertyName("", 1, 0, "SomeAnotherFieldName1"),//change FieldName

 

Can anyone tell me how to set or change the Name for DataTest[i], i=0,1,2... with API function?

 

 

Thank you!

0 Kudos
Message 1 of 4
(712 Views)

Until now,I wan't even aware that it is possible to assign a name to array elements....

 

Yet, I have to admit, I regard this kind of name assigment as problematic. 

If you have the neccessity to assign individual names to the data sets, I'd strongly recommend having an according element in the container.

Also make sure to use a custom data type with proper versioning.

0 Kudos
Message 2 of 4
(661 Views)

Thank you for your comments. You may know that it is quite easy to assign a Name or key to an array directly in Teststand without using API:

e.g. DataTest[0].Name = "SomeName0", DataTest[1].Name = "SomeName1", ......

The benefit to do this is for a direct and quick search some element within an Array by using the Name or key such as DataTest["SomeName0"] instead of basing on index like DataTest[0].

There should be  API solution for the same with other languages as an interface. If we do not have one API function for it, then as you said, we need to consider to convert an array into Container and convert it back to array.

0 Kudos
Message 3 of 4
(651 Views)

Since the SequenceEditor is based entirely on API, it is surely possible, at least in some weird way.

 

My point is: not every functionality that SeqEdit (and TestStand as a whole) offers makes sense in terms of clean coding 😉

 

0 Kudos
Message 4 of 4
(640 Views)