LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When to use local variables and shared variables?

Dear Labview gurus,

What is the difference between local variables and shared variables? What are the appropriate situations in which I should use shared variables?
0 Kudos
Message 1 of 5
(7,222 Views)
See if the informarion suppied on ni website it's enough for you~:

shared variable:
http://zone.ni.com/devzone/cda/tut/p/id/4679
(normaly to pass values in the network)

local variable:
It's used to pass values inside a .vi
Software developer
www.mcm-electronics.com





PORTUGAL
Message 2 of 5
(7,205 Views)
What is the difference between a single-process shared variable and a local variable?
0 Kudos
Message 3 of 5
(7,129 Views)
A local variable is local to the VI in which it's declared and used. It has no scope outside that one VI.

A single process shared variable can pass information throughout a single instance of your application. It has no scope outside that single instance.
0 Kudos
Message 4 of 5
(7,100 Views)


@mattyG wrote:
What is the difference between a single-process shared variable and a local variable?


A single process shared variable is more like a global variable, because it can be accessed from any VI in your hierarchy. Local variables are strictly local to the single VI where they reside.

Shared variables are a relatively new feature, while local and global variables are ancient. As such, shared variables are in many ways more modern and integrate better into state-of-the-art coding guidelines.

  • Shared variables contain error terminals so you can enforce execution order. local variables have no such thing.
  • A shared variable can stand on its own, while a local variable is always tied to a front panel object.
  • You need a project for shared varaibles.

You can easily turn a single process shared variable into a network shared variable later in the development, without the need to rewrite any code.

Message 5 of 5
(7,091 Views)