11-23-2009 03:28 PM
I'm building an app with 6-8 pulldown ComboBoxes, and each one will be first cleared and then populated based on a file. I've written a small vi to do exactly what I want, but I can't figure out how to pass the PropertyNode:StringsAndValues[] from each ComboBox to the subvi? I'd really hate to have to reproduce this code 6-8 times in my main VI.
The first thing I noticed is that my original small VI used the Flat Sequence Structure to make sure that I first Clear out the ComboBox and then populate it -- LabView wouldn't even accept this as a subvi when I tried to add it to my main VI, so I'm breaking the Clearing out into 1 subvi and the populating into another. I tried to setup the Clearing VI first which is when I noticed that I had found no means of referencing the original ComboBox in my subvi.
Anyone with some ideas?
Steve
Solved! Go to Solution.
11-23-2009 03:44 PM
Just a thought, control reference and property nodes
11-23-2009 03:47 PM - edited 11-23-2009 03:49 PM
Create a reference from one of the combobox terminals, then create a control from that reference. cut/paste the control into the subVI and use it as a control to pass the reference into the subVI.
are you using create->property node->(property)? That's less useful: Look on the application control pane for the regular property node primitive
here's what these look like:
once your subVI accepts a comboBox ref, you can put your 6-8 combobox refs into an array and then call your subVIs in a for loop.
-B
11-23-2009 03:58 PM
11-24-2009 08:25 AM - edited 11-24-2009 08:28 AM
Ah Ha!!!
It took me a few tries, but I finally realized that I had to pass the ComboBox REF to my subVI (which is exactly what you said;)), and not the StringsAndValues[] property. Like I said, I'm still learning LV after many many years of C programming, and it's a lot for my old brain to absorb. Thanks for expanding my understanding of LV.
11-24-2009 01:32 PM
glad I could help!
Say, how are you clearing the comboboxes? Couldn't you just overwrite existing values?
If you are going to build this application into an executable, don't depend on the strings[] or stringsandvalues[] lists to be retained between executions. (it sounds like you're doing the right thing though)
11-24-2009 04:46 PM - edited 11-24-2009 04:47 PM
I'm planning for the possibility of re-populating my list while the VI is running, and during development, I noticed that the control gives an error if identical elements are entered (I ran into this when re-populating it with the same strings), so to avoid that, I thought the easiest was was to clear it out competely first...Here's how I did it in my new subvi...
Thats an 'Array Size' vi on the bottom, and a 'Delete fromArray' above and to the right of it.
And, yes, this is a compiled executable, with different ComboBox lists so I have to be able to populate the list 'on the fly'.
11-24-2009 08:58 PM
ah, ok. that works, and it's kind of clever. but it's just deleting the whole array, so you could just wire a null array constant to the write property node and eliminate the read PN.
note the right hand error case of PJS's code is a routine for adding one item to the combobox's list (checking first to see if it exists).
It's also a good habit to use the error wires