BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Why some people say Local Variables are bad...

As i understand this was once a C program, yes. The picture is from one sub-vi i have inherited, so it's not my code. I'm sure i do my fair share of GDC and other mistakes, but this one isn't mine. 😉

 

I've read your nugget on AE's and i've tried it in a connected project. There's been a few connected project where i've been able to start from scratch and done event driven constructions which i'm pretty happy with. There are a couple of ugly solutions here and there, but generally feels like it follows the guidelines from these forums.

 

/Y

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 161 of 396
(8,204 Views)

Found here:  http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=481408#M481408

 

Not only was the code Rube Goldberg (convert to double would have done the trick), it also uses Local Variables instead of wiring directly.

The snippet messed up the diagram..  My guess is that snippets do not like Locals either..  😉

 

Wiring directly would have eliminated 2 indicators and 2 Locals  plus eliminated the need for a Flat Sequence Structure...  An added bonus would have been cleaner code.

 

 

 

 

 

Message Edited by Ray.R on 03-11-2010 08:03 AM
Message 162 of 396
(8,133 Views)

Ray.R wrote:

The snippet messed up the diagram..  My guess is that snippets do not like Locals either..  😉


Snippets convert locals and static property nodes to strict nodes.

Richard






Message 163 of 396
(8,117 Views)

Makes sense.. 

I still like the idea that snippets don't like Locals..  LOL!!  😄

Message 164 of 396
(8,114 Views)

Ray.R wrote:

Makes sense.. 

I still like the idea that snippets don't like Locals..  LOL!!  😄


 

Being from Florida, I like the Locals, but I appreciate the fact that Globals keep me from paying state income tax!
Richard






Message 165 of 396
(8,114 Views)

Ray.R wrote: 

Wiring directly would have eliminated 2 indicators and 2 Locals  plus eliminated the need for a Flat Sequence Structure... 


 

 
You cannot wire directly, because the indicators are in opposite cases, so one remains stale with each call. Thus we need a feedback node as discussed in the original thread. (Or this idea ;))
0 Kudos
Message 166 of 396
(8,117 Views)
I jumped too quickly on that  "Bandwagon" and ended up making a fool of myself for not reading the first post.  Maybe I should redeem myself by posting the actual solution..
0 Kudos
Message 167 of 396
(8,103 Views)

Ooo!  Ooo!  Ooo!

 

Here we not only wire to both the indicator AND a local variable of itself, we also have ANOTHER local variable sitting right inside the loop!

 

localitis again.PNG

 

Spotted here.

Message 168 of 396
(8,011 Views)

How helpful is this suggestion??? (compare with the actual question!)

 

 

Message Edited by altenbach on 03-19-2010 01:35 PM
Message 169 of 396
(7,961 Views)
I am sure AndyC was just showing how to to use the property nodeSmiley Very Happy
Regards
Ray Farmer
0 Kudos
Message 170 of 396
(7,908 Views)