LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a Global Variable through the Project Explorer

Solved!
Go to solution

Hi Everyone!

 

I know how to create a global variable (in a vi through the functions pallette....),

but i am missing a way to create one via the Project Explorer.

 

Is this a missing feature or just that documentation (and intuition from myself) is missing?

 

It would be very handy.

 

THX for your time and hopefully answers.

jwscs


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 1 of 9
(6,785 Views)

Hi jwscs,

 

why do you need global variables at all?

I haven't created them for years now…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(6,776 Views)

You can create shared variables from the project, but not globals.

 

Why do you need to create new global variables from the project? If you're working with enough globals to need this functionality, you're probably using too many.

 

Edit: I even looked in the New menu and didn't see it. Smiley Embarassed

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 3 of 9
(6,771 Views)

nice answer .. mr. deflect 😛

 

i just needed a container for my config settings, accessable globally,

and changeable.

and found it tedious to first start some .vi and create the global.

 

possible race-conditions don't matter in my usecase.

 

:cheers:


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 4 of 9
(6,766 Views)

@jwscs wrote:

nice answer .. mr. deflect 😛

 

i just needed a container for my config settings, accessable globally,

and changeable.

and found it tedious to first start some .vi and create the global.

 

possible race-conditions don't matter in my usecase.

 

:cheers:


I'm of the unpopular opinion that if you know the global variable will be the easiest way for you to do one thing and you're not over-doing it, go for it.

But why do you need to do it from the project explorer? You only need to create the global variable once and then you can find it in the project. You'll need to make a VI to access the global anyways.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 9
(6,759 Views)
Solution
Accepted by topic author jwscs

Right-click My Computer > New > New... > Select Global Variable.

 

EDIT:  Although I do agree with Gerd (he's probably asking why you need it so we can recommend a better way Smiley Wink), I do use them very occasionally in simple Write Once -Read Many (WORM) applications like setting overall program security levels on initialization to be read later but NOT modified.  I know it would be better to do a proper Class,  Functional Global Variable (FGV) or Action Engine (AE) but globals ARE convenient and safe IF used wisely.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 6 of 9
(6,756 Views)

@niquist thx .. i've never got that far 😉

 

@everyone else: i see your points, but as i stated race-conditions don't matter in my use-case,

but some examples what you use instead would be appreciated.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 9
(6,747 Views)

One powerful option to globals is the Action Engine:  http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/td-p/503801

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 8 of 9
(6,739 Views)

jwscs wrote:  but some examples what you use instead would be appreciated.

It really depends on what you want to do with the global variable.

 

I really like them for "constants": values you use everywhere and they do not change during the course of the program.

 

But since we are mentioning race conditions, I recommend you give this a quick look: https://decibel.ni.com/content/docs/DOC-41734



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 9
(6,712 Views)