Jump to content

Returning Data From a SubVi


Recommended Posts

Hi,

I'm currently modifying a medium complex app and I'm trying to use a SubVI to help improve the Main VIs readability. Currently I am trying to replace a part of the program and first makes visible two numerical controls, three boolean controls and a buton, loops until the buton is pressed (until the user enters data in the controls and presses the button), then makes these same controls invisible. The data in these controls are then used in the rest of the program. I would like to replace this structure with a single sub vi with the same controls so that it pops up, the user enters data and then closes the subvi with a button, passing the entered data to the main program. I am currently having issues because the connector pallete seems to only accept inputs (despite the word "output" frequently occuring in the help documentation). I suspect I might need indicators instead of controls to wire outputs, but this is counterintuitive, because indicators should indicate inputed data, not outputing data. And anyway, that won't help me collect data from the user. I want to avoid setting visibility and I want to avoid looping until the buton is pressed. Can anyone address this specific issue or make a better suggestion of how to implement this?

-Tyler Shogren

Link to comment

The way I've always done this, and I believe it's the standard approach, is to put controls on the front panel along with matching indicators. Wire the indicators to the connector pane, then hide them. On the block diagram, wait until the user presses the button (using a loop or an event structure), then pass the values from the controls to their corresponding indicators. Make sure that the copy from the control to the indicator happens only after the button is pressed.

If you use an event structure, be warned that sometimes events may not fire in exactly the order you expect. In particular, say you allow the "Enter" key to toggle your button. If you enter a value into a numeric control, then hit Enter, the boolean event will fire before the value of the control is officially changed. So, if you copy the value of the numeric control into an indicator in the boolean event case, you'll get the previous value of the numeric. Don't worry if this doesn't make sense to you - if you do use an event structure and your numeric values are inexplicably wrong, look back on this post and it will probably make more sense.

On a side note, does anyone else ever use an event structure outside a loop when you just want a VI to wait until a single event (Window close, button click, etc.) occurs before terminating the VI?

Link to comment

QUOTE (tcplomp @ Jun 9 2008, 02:28 PM)

Instead of hiding I create a user-visible part inside a decoration, and with OpenG functions I limit the visible part to this decoration.

That's the best way to do it - and then, if you like, you can use an OpenG function to rezie the FP to all contols/indicators at the end of execution. It's bad form to hide FP nodes unless you really need to - if you don't want the user to interact with them, it's often better to make them disabled and grayed.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.