LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Block diagram for multiple text boxes

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

0 Kudos
Message 1 of 17
(2,834 Views)

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.

0 Kudos
Message 2 of 17
(2,829 Views)

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!

0 Kudos
Message 3 of 17
(2,819 Views)

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!

0 Kudos
Message 4 of 17
(2,812 Views)

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.

0 Kudos
Message 5 of 17
(2,797 Views)

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.

0 Kudos
Message 6 of 17
(2,784 Views)

Post the VI and I will edit it.

Message 7 of 17
(2,771 Views)
0 Kudos
Message 8 of 17
(2,769 Views)

This would be a subVI.

0 Kudos
Message 9 of 17
(2,757 Views)

@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.

0 Kudos
Message 10 of 17
(2,752 Views)