11-26-2008 03:44 PM
Happy Thanksgiving everyone. I have a simple yet complicated problem.
I have an empty array of one dimension . I also have a numeric control. Whenever the user adjust the control say to 3, the number of elements available in the array should be 3. Then the user can now input the values he wants in the array.
so if the user adjusts the numeric control to say 7, there should be 7 elements available in the array. then the user can now enter seven values in the array.
Thanks
11-26-2008 04:18 PM
ade,
It seems like an event driven array redim type operation. I would put an event structure on your block diagram and construct a resized array on the value change event of your numeric control. I attached a vi that will resize and preserve the contents. It is a bit simpler problem if you don't need to keep the current contents of the array when it is resized. This works for a 1D array, but could probably be extended for a 2D. (LabVIEW 8.5)
Cheers
-cb
11-26-2008 04:21 PM
You can use reshape array to pad or trim a 1D array to a new length. Try it. 🙂
Since this is a control, you would need to write the new data to the control via a local varaible, for example.
In addition, you might want to hide the array index display and change the number of visible elements on the front panel via a property node. Otherwise, the user could easily click on an element outside the desired size and thus increase it beyond the intent of the programmer. (remember, the number of visible elements is completey unrelated to the array size).
Further details depend on the rest of your code. If you give us more details (or attach your program) we might be able to give more specific advice. 🙂
11-26-2008 05:12 PM - edited 11-26-2008 05:13 PM
Here's a quick example (LV 8.0). See if it makes sense.