LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Smart solution for index variables from array in a human legible way?

Hello everyone,

 

I have a project where I have many variables arranged in arrays. Every array is in the order of 100 variables. Sometimes I have to do the same processing or calculation to all the variables, so in this case is easy. But other times I have to select only some variables (1, 2, 4, 15...) to do some concrete operations, or to do different operations depending on the index. I can't find a way to index this variables in a clear and clean way.

 

I started thinking about using multicolumn listboxes. I have a typedef listbox for each array type (3) with the name and other info of each variable inside the array, and every time I have to index some variables I deploy the right typedef listbox on the vi front panel and select the variables I want from the list. Then I index the array with the indexes returned by the listbox (with the index 1D array Elements OpenG VI). But this way the front panel and the diagram are messy and not clear.

 

I thinked also to replace the typedef lisboxes by typedef enums, and use them to index the array. This way the front panel and the diagram are cleaner, but I miss the extra information of the multicolumn listbox and will be more cumbersome to index a big amount of variables.

 

I don't want to implement a bad solution. What I want is to avoid to index the array with numbers but do it in a more human legible way. And do it with clean and flexible (increase and modify the variables) code. There is any other solution that can be adopted to this kind of situations.

 

Best regards and thanks for your time,

 

 

EMCCi

0 Kudos
Message 1 of 18
(3,667 Views)

Your description is very vague (e.g. what exactly are "concrete operations" or "different operations"?). Are you looking for better code or for a better UI? What does the operator need to do? How does existing commercial software do similar things?

0 Kudos
Message 2 of 18
(3,659 Views)

Sorry if the description is vague. I have already programated the VI that do all the operations I need, what I'm searching for is to feed this VI with data in a legible way, so better code. This has nothing to do with the user.

0 Kudos
Message 3 of 18
(3,650 Views)

Can the variables be grouped in any way to make it easier to find a certain variable?  If so, maybe a tree structure makes more sense. 

aputman
Message 4 of 18
(3,648 Views)

@EMCCi wrote:

But this way the front panel and the diagram are messy and not clear.

 

I thinked also to replace the typedef lisboxes by typedef enums, and use them to index the array. This way the front panel and the diagram are cleaner, but I miss the extra information of the multicolumn listbox and will be more cumbersome to index a big amount of variables.

 


If this doesn't involve the user, why do you mention front panel and multicolumn listbox? 

aputman
0 Kudos
Message 5 of 18
(3,643 Views)

What about using key-value pairs with Variant attributes? Or any of those "Tag"-based implementations?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 18
(3,640 Views)

@EMCCi wrote:

This has nothing to do with the user.


OK, so the "human" in "human legible way" is the programmer, not the user?

 

If this is strictly about cleaner programming, we still need much more information. Do you just need selective operations on some elements or do you need new arrays containing only the subset of values based on the selected indices?

0 Kudos
Message 7 of 18
(3,623 Views)

A couple of images to go with your description would help us understand the challenge.

 

Would an array of Enums help using the enum to index elements from an array?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 18
(3,606 Views)

Something like this?

index variables from array in a human legible way.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 18
(3,566 Views)

Ok, sorry again if the description of my question is not good enought.

 


OK, so the "human" in "human legible way" is the programmer, not the user?


Yes.

 


Do you just need selective operations on some elements or do you need new arrays containing only the subset of values based on the selected indices?

Both. I sometimes need to do selective operations on some elements (like modifying, creation of new variables that will be appended again to the original array for further processing, pass band filters...), and others times I need to select the whole array or a subset of it, and serve it to another part of the code.

 

If this doesn't involve the user, why do you mention front panel and multicolumn listbox? 

Because at the very first I thought about using multicolumn listboxes as a way to index the array in a clear way for me and whoever reads the code. The only reason why I mentioned the FP is because listboxes have to be placed in the FP in order to see the name of what you are selecting. For example:

image.png

Then with the array of indexes I would index the array of variables. But the listbox will not be used as a control but as a constant, and of course will not be connected to the subvi terminals. But then, read the code can be tricky because part of the info is on the block diagram, and other on the FP. And when the number of listboxes increase can be difficult to keep ir ordered.

 


@Ben  ha escrito:

A couple of images to go with your description would help us understand the challenge.

 

Would an array of Enums help using the enum to index elements from an array?

 

Ben


This is the second option I have thinked about. The colde will be better ordered, but I will lose the extra information that a multicolumn listbox allows that can be useful to keep ideas clear while programming. Also will be more cumbersome to select big amount of data. But I think that in general is a better solution.

 

But the point here, is that I'm into labview (and into programming) a year and half because LV has been my first programming language. So, I'm afraid of being reinventing the wheel with my ideas, meanwhile there is a traditional better way in the programation world to face this kind of situations. For example this:

 

What about using key-value pairs with Variant attributes? Or any of those "Tag"-based implementations?

Don't know what these concepts are, and have never used them before. I'm trying to understand what they are and if they can be useful for me in this situation.

 

I hope that now the situation to be better explained. Thanks all you for your time. Best regards,

 

 

EMCCi

0 Kudos
Message 10 of 18
(3,560 Views)