LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

wire or local variable?

What you are suggesting would make the diagram dirtier, not cleaner. Use linked input tunnels and a cleanly layed out diagram and these wires won't cause any congestion.

 

Especially if the code is already all wired up, it seems silly to mess it up with some misguided idea of cleanliness. 😉

0 Kudos
Message 31 of 33
(1,005 Views)

While both the local and the global would work, and in the case of a single refnum they won't make a noticable difference, I would advise not doing that either, mainly from a safety and cleanliness point of view. As far as readibility goes, I agree that locals can make code easier to read and write. Rather than having unneeded wires all over, you only have the data where you need it and it's easy to find all the callers with a right click, so a local wins there. It does make it easier, however, to create race conditions by interacting with the same resource from more than one place in parallel and once your code has many locals or globals, it can sometimes be hard to figure out the relationship between the different parts of the code.

 

Some additional options:

 

  1. Use a single cluster with all the data in the shift register. This allows you to only access the specific data you need in each case and because it's a wire, you can't touch it from other places.
  2. Use another mechanism, like an action engine - http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801
    This can allow you to hide the details of the UDP connection entirely and simplifies the caller into a simple call to a write VI, which deals with the connection internally.

___________________
Try to take over the world!
Message 32 of 33
(972 Views)

sjandrew wrote:

Edit - I only have one VI, but the comment above suggests that global variables would work in this situation: any reason to use a global over a local?


A global does not dirty up your front panel and it is a little faster.  However, since you are dealing with just a single VI, I would just stick with the wires as they will absolutely be the fastest and avoids race conditions.  But if you really insist on getting away from using the wires, then the Action Engine is the way I would go.



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
0 Kudos
Message 33 of 33
(941 Views)