11-14-2012 01:01 PM
I have ten text boxes (string controls) on my front panel. Each has a push button next to it. When text is typed into the field and the corresponding button is pressed, the text box and the button are disabled and grayed out. See the attached image for the block diagram and the front panel.
The issue I'm having is the block diagram for the ten tex boxes is obnoxiously large (the image only shows 4 of the 10 case structures). And it's the exact same code copied 10 times, with only the component names being different. If I make one tiny change, I have to tediously repeat the same change ten times. Is there any way to "functionalize" this code or otherwise reduce the repetition?
Thanks,
Dan
11-14-2012 01:07 PM
Make it a subVI. And you can use references of each control so the subVI know which specific control to act on.
You can probably go a bit further and build the references into an Array so that depending on which button is true, it can index out which particular reference in the array to send to the subVI. Since you are dealing with user interaction, you may want to use an Event Structure to determine when the control has changed. The event structure will provide a control reference that you could wire into the subVI.
11-14-2012 01:36 PM
Ah, references are the key here. I was thinking I couldn't make a subVI because I wanted the controls on the main front panel. But I think I see now how to use references. I'll have to read up a bit more.
Thanks!
11-14-2012 02:22 PM - edited 11-14-2012 02:23 PM
Ok, I'm getting a little confused. I'm finding lots of information about using references that are tied to a specific control on the front panel. However, I want to make a subVI that can accept a range of controls wired to it. So I can place the same subVI 10 times in my main block diagram and wire a different button and string control to each one. Am I thinking along the right lines?
Thanks!
11-14-2012 02:47 PM - edited 11-14-2012 02:48 PM
I think what you are looking for is to have a generic property node that you can feed a reference in to. You can create one by selecting: Application Control -> Property Node. Once you have the node, you right click: Select Class -> Vi ->Generic -> Object -> Control (or something like that).
Edit: Once you have that, you can create a control in to the reference node, and link it to a VI terminal.
11-14-2012 03:25 PM
Ok, thanks Aalenox. I think I'm almost there, but I'm getting hung up on one part. I have a property node and I selected the following class:
Generic -> GObject -> Control -> Boolean
I specifically chose Boolean because it's a boolean pushbutton. See the image attached. The hang up is how to get the value of "Mark" into the case structure. If I select the "Value" property from the property node, it won't let me wire it directly to the case structure. It claims it's of type "variant". I'm pretty far outside my understanding of LabView here, so I'm not sure where to go next.
11-14-2012 03:49 PM
Post the VI and I will edit it.
11-14-2012 03:51 PM
Thanks.
11-14-2012 04:09 PM
This would be a subVI.
11-14-2012 04:16 PM - edited 11-14-2012 04:17 PM
@RavensFan wrote:
This would be a subVI.
That is the correct sub VI, but unless you have more stuff in your main VI, I don't think it is going to do what you need it to.
Here is another approach. It isn't the best possible option, but it will work for what you are asking.
Edit: For this you will want to use latch type booleans, not switch.