LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Global Variable outside of Projects

Hello all

 

I am writing a rather large program in LV8.5 and am currently writing a lot of different VI's to be put together later as the compiled project. For now I am just writing and testing each VI separately. At some point at the beginning of the compiled VI, I will prompt the user to input which "Quarter Section" is being tested (1-4). 

 

What I would like to learn how to do is be able to take that 1-4 value, put it into a variable at the beginning of this mess, and be able to retrieve it at any arbitrary point down the line without using controls/indicators to cut down on usless wiring and unnecessary inputs/outputs in the other VIs. I basically want a global variable, but to my knowledge globals only transfer between VIs in the same project. How can I get around this?

0 Kudos
Message 1 of 10
(3,812 Views)

Hi jaysmall,

afaik the global is automatically part of your project if you use it in your project. You can also use global functional variables to transfer data, but if it´s possible use controls and wires.

 

Mike

0 Kudos
Message 2 of 10
(3,799 Views)

Mike,

 

How do I change the global variable type? I am trying to write a numeric constant to it to use later, but its type is void and won't let me wire a number to it.

0 Kudos
Message 3 of 10
(3,788 Views)
Never mind, got it. Needed to put a numeric indicator on the front panel of the GV.
0 Kudos
Message 4 of 10
(3,784 Views)

It should be pointed out that traditional Globals are generally considered bad programming practice in LabVIEW, and you might want to replace the global with a Functional Global / Action Engine.  Functional Globals aren't really globals in the normal sense, but rather subVI's that make use of some of LabVIEWs percularities to store a state between calls.  They have several advantages over traditional globals as well.

 

http://forums.ni.com/ni/board/message?board.id=170&thread.id=240328&view=by_date_ascending&page=1

Is Ben's nugget about them.

Jon D
Certified LabVIEW Developer.
0 Kudos
Message 5 of 10
(3,778 Views)

Thank you for referring me to that. What a great exploit of LV functionality.

 

Though unless I skimmed too fast and missed something, I did not see a reason for superiority over a GV for my purpose. If there is, please let me know. I am just saving a 1-4 state.

0 Kudos
Message 6 of 10
(3,775 Views)
From the way you are describing things for something that small, your main advantage is that you don't have to worry about race conditions as much.
Jon D
Certified LabVIEW Developer.
0 Kudos
Message 7 of 10
(3,760 Views)

Alright, using LV8.5 I can't seem to make this Functional Global work...

 

What am I doing wrong?

0 Kudos
Message 8 of 10
(3,743 Views)

You had the input attached to the read of the left most shift register.  Attached the fixed FG.

 

Basically, on a write you switch the input of the shift register (The right side of the register) to the input value, overwriting the earlier value.  This is the value that will be read later.

Jon D
Certified LabVIEW Developer.
0 Kudos
Message 9 of 10
(3,736 Views)
Got it, thanks for the info
0 Kudos
Message 10 of 10
(3,733 Views)