06-10-2012 02:54 AM
Hi,
I am trying to have an array of numbers which displays which value of the combo box is choosen.
For example, if we choose a string "hello" which is at number 3 in the drop down list in the combo box, the third element of the numerical array should change to 1 to show that the third string was selected (and this value should be retained for successive iterations).
06-10-2012 06:21 AM
Hmm, makes me curious.
3th in drop down combobox, so 3th element of the array (probably 2) and the value you want to get is 1?
06-10-2012 06:41 AM
Your requirements are not clear. You say "value", but you seem to be referring to the index of the item selected. What are the other elements of this array supposed to show?
Based on the little that you've indicated, initialize an array with blank/default values, and then in your program, simply replace the array element when the combo box selection is made. I am assuming you have an event structure.
06-10-2012 09:06 AM
If i understand correctly it's rather simple.
The Value of the combo box is the index chosen (let's call it X). Change the X position of your numerical array to True or 1 or +1 (depending on your design) with a replace array subset.
Keep the numerical array in a shift register or Action engine.
/Y
06-12-2012 03:25 AM
Hi,
I have been working on it and this is what i came up with (see attached file). In this program the user can choose any string form the combo box and the program will compute the string length and display it in the array at the specific point, e.g. if the user chooses the third number string the third element in the array will be changed.
However, the problem is that each time the user chooses a string all other array elements turn to zero. I want them to retain their value. how can i do that? Please if any one can modify my program it would be a great help because my whole project is stuck due to this little glitch. .
Also i noticed that the first array element does not change? why is that?
Thanx
06-12-2012 03:25 AM - edited 06-12-2012 03:28 AM
Btw its the same problem that i stated before the only difference is that instead of putting in only +1 or -1 I am inserting string lengths
06-12-2012 03:41 AM - edited 06-12-2012 03:42 AM
@Mylo wrote:
Also i noticed that the first array element does not change? why is that?
Thanx
The Case structure is case sensitive "Blah blah" does not equal "Blah Blah". The is an option to make the case structure
Case Insensitive
Right Click the structure and select "Case Insensitive Match"
Ken
06-12-2012 03:46 AM
@Mylo wrote:
Hi,
I have been working on it and this is what i came up with (see attached file). In this program the user can choose any string form the combo box and the program will compute the string length and display it in the array at the specific point, e.g. if the user chooses the third number string the third element in the array will be changed.
However, the problem is that each time the user chooses a string all other array elements turn to zero. I want them to retain their value. how can i do that? Please if any one can modify my program it would be a great help because my whole project is stuck due to this little glitch. .
Also i noticed that the first array element does not change? why is that?
Thanx
Since you have 3 empty exits of your case structure those will be 0'd. That's why you need the Index of the combo box (property node probably) and change only that one, else you're on the right track.
/Y
06-12-2012 03:47 AM - edited 06-12-2012 03:55 AM
Run the vi with highlight execution on and you will see that you are inserting all elements into the array on every loop the unwired ones from the case structure defaulting to zero.
you need to use the index of he combo box
You could use a Test Ring rather than a Combo Box - you get the index for free and you can get the string by indexing the Strings[ ] property
Ken
06-12-2012 04:00 AM
With a Text Ring as Ken says you'll get the index directly and can get the text through a property, with the combo box you get the text directly and need to use Search array through Array[] property to get the index.
Different controls, different strengths.
/Y