LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Ray.R

Convert Global to Shared Variable

Status: Declined
Declined because functionality might make people think that Globals and Shared Variables behave exactly the same when in fact they don't.

After reading a rather heated discussion about converting Globals to Functional Globals, I was made aware that you can convert the Shared Variables to Globals, but not the other way around.  How strange.

 

I will not enter the debate that I liked Steve's idea, especially for debugging purposes.  But what if we could convert the Globals to Shared Variables?  They have the error cluster in and out..  Which would force dataflow.  Much better than wrapping the Global inside a Flat Sequence Structure and run the error wire through the Flat Sequence in order to force dataflow.

 

I did a quick search and to my surprise, I did not see such an idea being proposed.  Apologies, if I missed it.

 

I do offer these links if you are interested in reading the other G to FG discussions.

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Convert-Global-Variable-To-Functional-Global/idc-p/152...

http://forums.ni.com/t5/LabVIEW/Global-Variables-Are-Better-than-Functional-Globals-So-There/td-p/15...

 

 

 

6 Comments
Ray.R
Knight of NI

As life would have it, I just happen to have a client which would have needed such a feature.  Their problem is rather unique..  well.. maybe not.  I will describe their issue and how they solved it.

 

They created a "test executive" executable, written in LabVIEW.  It's a standalone program that calls other executables which actually carry out the tests.  Basically, how this breaksdown is that the main program is the test executive.  The tests are also written in LabVIEW and compiled as executables.  It is done this way to allow sending new tests to their client without their clients having to install new executives. 

 

The way they send data to and from the test executive to the actual tests are using Shared Variables.  Before separating the executive from the tests, the data was passed to & from using Globals.  I do realize that it may be tricky to convert Globals into Shared Variables, but such an option would have been useful.

 

I think it may also be useful for the people who are learning more about LabVIEW as they use it and possibly visit these forums, and eventually realize that they really wanted to use Shared Variables instread of Globals.  Such a feature would provide a simpler means to accomplish the transition.

 

 

The intent of this feature is NOT to suggest that Globals are evil and that they should be replaced with Shared Variables...

Brian_Powell
Active Participant

My enormous concern with this suggestion is that shared variables do not behave the same as global variables.

 

If I write to a global and then read from it, I will get the value I wrote.  This is not true for shared variables; you have to wait for the value to make it to the shared variable engine before reading it returns the value you wrote.  I could go on for pages about why I dislike shared variables, and don't really want this idea to degrade into that.

 

Bringing this back to the idea at hand, I'm concerned that making it easy to convert from globals to shared variables will give the wrong impression about how easy it is to convert an application to use them.

 

Ray.R
Knight of NI

Thank you Brian for the insight.

 

I must admit that I was not much of a fan of shared variables.  As a maater of fact, I did not see a reason to use them until now.  (I will not go over the debate of proper coding as it was not my decision to go in that direction)

 

I would like to find out your other reasons for not wanting to use Shared Variables... Could you post a Nugget on the subject?

 

I can see why this idea is not a good idea after all.  Now I wish I could make it dissappear 😉

Maybe if I asked Laura 🙂

 

Brian_Powell
Active Participant

There are several other discussions about shared variables that I could point you to...

 

http://lavag.org/topic/13524-worst-labview-design-feature/ (search for "shared variable")

 

Also, one of the Colorado LabVIEW User Groups (ALARM) has been discussing it for months...

http://decibel.ni.com/content/groups/alarm?view=documents

 

My top three complaints...

1) No write-through cache within a LabVIEW process (symptom is the one I described above)

2) You have to play tricks (or pay extra money) to reliably initialize a shared variable

3) Default configuration of shared variables varies depending on which NI products you have installed

 

Ray.R
Knight of NI

Thanks Brian,

 

You are giving me ammunition to (try to) convince my client that their current approach is not sound.  I will prepare a stong case.

 

Hopefully people read this thread before voting for this feature. 

 

Well... this is a first... Asking people NOT to give me kudos!  😄

The main thing is that I learned something.

 

Thanks!

 

G-Money
NI Employee (retired)
Status changed to: Declined
Declined because functionality might make people think that Globals and Shared Variables behave exactly the same when in fact they don't.