NI TestStand Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
MimiKLM

Better binding. Introduce additional array element loop variable called Current Name.

Status: New

Hi,

Before proposal a bit of introduction.

It is not well known feature that we can name the containers. This feature can be very useful if we consider naming the array elements. Using it we can access array elements not by index but by the name we give them.

To illustrate this feature please have a look at the picture below.

 

Capture01.PNG


Using this feature we can access elements not only like that

 

Locals.Cnt[0]
Locals.Cnt[1]
...

 


But like that as well.

 

Locals.Cnt["P112"]
Locals.Cnt["P113"]
...

 


This is an existing feature. What is new then?

The proposal:

For all looping steps For For  Each I'd like to propose to introduce additional array element loop variable called Current Name.

In this field devs could reference a variable which will be storing the name of the

What is beneficial?

Using this we can access element of the array of cluster independently from their location in the array and proposed idea will let easily access to the elements from within the loop. We can bind against the name not the index only.

O course it would be even more beneficial even devs could name element array of ANY type not containers only.

We can also name  the elements of the array which consists of containers. In this way we can have nice binding method and instead call the array elements vie index we can call them by its name (string). The postulate additional array element loop variable could be just below the current subscript form. The current view of the For Each Loop looks like below.

 

Image.png

The benefit of this additional array would be that we would know the current name of the element and we could call this element using its name not a number. Then developers could use that name to call the element in that loop by using its name.

4 Comments
Scott_Richardson
Active Participant

MimiKLM, you may already know this; if you define a CurrentElement property, you can use the expression NameOf(Locals.CurrentElement) or use the API Locals.CurrentElement.Name to obtain the name of the element. I do understand that this requires that you define a variable for the current element.

Scott Richardson
MimiKLM
Active Participant

Yes, I was aware of API and I use it.

 

The whole point is to expose it in this Array Element Loop Variable form to have direct access to it.

 

Yes, it would require (optionally) to define a variable for Current Element Name. Exactly as for other variables.

 

What do you think about this idea?

Scott_Richardson
Active Participant

MimiKLM, I understand your interest in this request. I am not sure how common of a use case this is and how to weight that against other suggestions; we will monitor the kudos for it. I have already recommended that we add a note to the documentation to call out how to obtain the name of the element.

Scott Richardson
MimiKLM
Active Participant

Hi Scott,

The main idea is that the naming the containers feature you develop is great but not videly used as, IMHO, only half of the job has been done :-). I mean you can name the cointenters, what in case of having in the code an array of containers could be very helpfull, but on the other hands you don't have a lot of handlers to use it. Of course you have them in the API called NameOf and *.Name but they are not existing in the forms. It'd be good when developers could have a direct access to the name of the element during looping.

 
The biggest underestimated advantage of having named array elements is to free up from the order of elements in the array.