LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create an array as long as wanted?

Hello!

We have an array that we can se in the frontpanel. But we want it to be as long as the numbers of elements, and the numbers of elements can be different every time. Can one control this in some way ? For example with a while-loop or something like that? Thank you! Best regards.
0 Kudos
Message 1 of 22
(4,461 Views)
We mean so that one can not drag the array out to see the empty elements after...
0 Kudos
Message 2 of 22
(4,461 Views)
You need to use property nodes to not allow the index value (that's the number of the first cell) to go over a certain limit. You can do this by making the index control invisible and using one of your own to control the index values, or you can disable the control, and determine where the user clicked, and whether the index should be changed, or (what I posted) you can calculate the size of the array, and if it shows too much, revert it. This has the disadvantage of correcting something a user did instead of preventing him from doing something, so I would suggest going with my first suggestion.

___________________
Try to take over the world!
0 Kudos
Message 3 of 22
(4,450 Views)
Hello tst!

Thank you for your help! Then we have another problem. That is that we have an array that we create as an indicator but we want to use it as a control. So to say, we get a certain numbers of element from a loop and then get an array, and then want to use this as a control, which we can choose what element we want to use. Can we do this in some way ? Best regards and thank you again for your help.
0 Kudos
Message 4 of 22
(4,447 Views)
The preferable way would be to use the wire you have coming out of the loop and just take the wire to where you want to use it, because this way you keep the dataflow structure and you avoid making additional copies of the data, thus conserving memory and processor time. If you still want to access a variable (control or indicator) other than where it's terminal is, right-click on it and select Create>>Local Variable. You can use this local variable as a read or write terminal. If you want your array to be a control, change it into a control and wire the data coming out of the loop into the local variable.

___________________
Try to take over the world!
0 Kudos
Message 5 of 22
(4,444 Views)
Hello again!

Our problem is as follows: We have a text-file with different (depending on wich textfile it is) numbers of elements. These elements we want to wright in an array on the frontpanel. Then we want to be able to choose with a checkmark or something so that the program knows that we has choosen that element from the array. The problem that we see is that the array with the element is an indicator and we want to be able to choose with a controler. We tried what you suggested, tst with local variable but the problem was that one can not go from string to boolean in a good way 😕 Any suggestions? Best regards.
0 Kudos
Message 6 of 22
(4,433 Views)
Hello Ex-jobb,

that's what I told you in a different thread:
make an array of boolean next to your array of strings. The string array can be an indicator, showing your elements form the text file. The boolean array is a control, where the user checks the desired strings. This way you don't need to access the string array as both control and indicator.

Best regards,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 22
(4,428 Views)
Hello Ex-jobb,

just an example to my last comment.
In the picture you see several arrays. The user can select the array entitled "use?", it's boolean. The other arrays are indicators, showing data elements read from a data file or calculated from that data file... The number of array elements is adapted to the number of items in the data file via property nodes (property "Number of Rows"/"NumRows"). Why not do it that way?

Best regards,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 22
(4,420 Views)
Hello GerdW!

Yes that we have done. The problem is that we want to have the boolean array in the same size as many string-elements. How can we make the rest of the array "gray" so that one can not click them? The best thing would be to get two arrays with the same size as numbers of elements. But how to do this? We get an array but then one can take in the corner and drag out the array. We would like it to become the same size directly on the frontpanel so that one don´t have to drag somewhere. Maybe this is a bad explanation... we hope that you understand what we mean... Thank you for your help. Best regards.
0 Kudos
Message 9 of 22
(4,422 Views)
The array cannot drag-enlarged when the VI is running, so you shouldn't have a problem there. Use a slide control to control the IndexVals property for both array and this way they will be aligned. To change the size during run-time, you can use the NumRows property.

___________________
Try to take over the world!
0 Kudos
Message 10 of 22
(4,413 Views)