01-22-2016 09:37 AM
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
Solved! Go to Solution.
01-22-2016 09:41 AM
01-22-2016 09:43 AM - edited 01-22-2016 09:49 AM
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. ![]()
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
01-22-2016 09:43 AM - edited 01-22-2016 09:44 AM
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:
01-22-2016 09:46 AM
@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> ---'
01-22-2016 09:46 AM - edited 01-22-2016 09:52 AM
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
), 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.
01-22-2016 09:49 AM
@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.
01-22-2016 09:57 AM
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
01-22-2016 10:22 AM
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