LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reducing Array Length Without Resetting the Array

Solved!
Go to solution

For an experiment control application I would like to use an array for experimenter input.  The experimenter will type in as many values as they choose, usually less than ten, and the LabView program will use each value based on the size of the array.  All is well on the initial setup and any further setup that needs more values, the array will grow nicely.  Should the next setup require fewer values the array continues to require values for the largest array entered until the array is initialized on start up.  A reset button will obviously reset the array but requires an additional control, user training, and frustration when forgotten and values entered before resetting.  Is there some way, for example deleting the excess values, to reduce the size of the array?

 

Also, can the tab or enter key be used to move between values in the array?

0 Kudos
Message 1 of 6
(2,705 Views)

You may be able to program an event structure that acts on the Key Down? event and if the key is a tab, and the array has focus, then select the next item in the array.

 

As for the reducing the size of the array question.  How do you want the user to be able to remove the "extra" elements in an array from a previous run?  How do you want the user to tell the program the difference between a newly entered value, a previously entered value that you want to keep, and a previously entered value that you want to remove.  That is more of a user interface question than a LabVIEW question.  How would you want the user to do this if you were in some other program?

 

Once you figure this out, then we could figure out how to make it happen.  Do you want the user to "blank" out the unused elements?  Than LabVIEW could find the blank element and trim the array back.  Perhaps instead of using an array, you might be better off using a table control.

0 Kudos
Message 2 of 6
(2,701 Views)

My first thought is the delete key.  Pressing delete would reset the element back to the undefined state (not sure I know what that state is but the grayed out state of an initialized array) and truncate the array to that length.

 

Thank you for your response to this question and to my previous one.

0 Kudos
Message 3 of 6
(2,681 Views)

As RavensFan mentioned, how you remove elements depends highly on your desired user interface.  

You could easily make a button for them to press which would delete the currently selected entry in the array.  

 

OR, you could replace the array with a listbox, allowing the user to select ALL entries they wish to delete before pressing a button.  

 

Replacing undesired entries with a zero, and then deleting all such entries.  

 

You could do the button option, but tie the button to a key command and hide it, this way a user could delete an entry by pressing CTRL + SHIFT + K (for example).... The list goes on and on.

 

The delete key is used to delete a number based on cursor positon (I highly recommend you choose an option that is not commonly used for something else).

0 Kudos
Message 4 of 6
(2,677 Views)
Solution
Accepted by topic author Indiana_Bill

Try this. I don't have time to clean it up at the moment.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 5 of 6
(2,665 Views)

Thank you this looks like a solution.  Parts of LabView I have never used.  Will take me a while to understand but the basic idea is clear.

 

Thanks to everyone who responded.

0 Kudos
Message 6 of 6
(2,654 Views)