LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i create and pass a global variable from one vi to several sub-vi's?

Hi Guys,

I am trying to create a program that opens several front panels (sub-VI's) in sequence. in each front panel, the user would open a file that the name is obtained from the previous sub-VI. I would like to know how i could pass the filename and refnum of the file thorough from one sub-vi to another. A global variable would do it in VB, but how do we do global vars in LABWIEW. thanks

Papish
0 Kudos
Message 1 of 6
(3,466 Views)
Papish,

You do not need global variables to do what you are asking. Simply create the subVIs with controls for the filename and refnum and wire to those. This is the dataflow pardigm which LabVIEW uses. You can set the subVI to open its panel when called and close the panel afterward. Look at the tutorial. It should show somw of these very basic techniques.

Global variables are available in the structures palette, if you really need them. Also a subVI containing an uninitialized shift register in a loop which executes only one time can serve a what is called a functional global or LabVIEW 2 style global. These may be customized for read, write, reset, and other uses.

Lynn
Message 2 of 6
(3,457 Views)
I put together a sample VI and Sub VI that illustrates how to pass a Refnum and access a data file while in a Sub VI.
For multiple VIs just repeat the sub VI process.
You probably don't wanna use a Global Variable if not needed (can add to the mess down the road haha).
Let me know if it helps you out! Or if I can clarify anything else!
Chances are if you have seen VI in the forest it hasn't fallen.
Message 3 of 6
(3,456 Views)
Thanks John and X,

I have had some problems though implementing what you both said. I cant create an input wire to my sub-VI, in other words, how do i create the input wire to my sub-VI, as it is now, i cant add an input or even wire to it, unless there is an input somehow, which is my problem now? As X did, but how did u wire it, please more details. Thanks
0 Kudos
Message 4 of 6
(3,449 Views)
OH! Quite easier than you think!
On the front panel display of the sub VI you will see the icon.
Right Click - Show Connector
Simply pick a pattern, click the terminal, and then click the actual indicator on the front panel. (many recommend using the wiring tool while doing this)

That fix you up?
Chances are if you have seen VI in the forest it hasn't fallen.
Message 5 of 6
(3,440 Views)
Briliant stuff, thanks X, you were of a great help.
Thanks again
Me
0 Kudos
Message 6 of 6
(3,434 Views)