LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having Trouble Copy and Pasteing Local Variable in LabVIEW 2010

 


@tbob wrote:

 

So please, everyone, stop saying locals are bad. 


Can we still say that the GOTO statement in Basic is bad? Smiley Very Happy

 

 

I agree with you, tbob, as I have never jumped on the "local variables are evil" bandwagon. I have, however, always tried to discourage their use for the reasons that have been already stated. I cannot speak for others, but as far as the comments regarding this thread "going off kilter"... well, I for one, was directly answering the poster's questions and not trying to turn this into a bully pulpit about local variables being the apocalypse.

0 Kudos
Message 41 of 43
(638 Views)

@OP Copy paste of a local will create a new control with a new local, if you want to duplicate an existing local ctrl+drag is the best way.

 

@Tbob Locals are generally bad, but sometimes lovely and the best solution. Often it feels better to simply advocate abstinence for the same reason saying "one glass of wine a day is good for your health" leads to some drinking 2 bottles. I feel it's mainly a top down vs bottom up view, instead of having a open firewall and block some bad ports (locals are ok but in a few instances) it's easier/better to go with full firewall lock and open safe ports (locals are good in these instances).

Meh, maybe i'm just rambling.

 

@OP It sounds like your state machine is safe and secure so this is general information.

The problem with locals is that LV is smarter than you. It reads and writes locals as fast as it can, not necessarily when you want. You can force execution by using another not very well liked structure, Sequence. Why not liked? It dumbs LV down and hinders parallellism, but just like with locals sometimes it's needed. 🙂

This combination is called Sequentitis and Localitis.

(A good example of this is when timing something, the clock doesn't have any error wires so to force when timing should start and stop you need to enclose it in a sequence frame with other code)

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 42 of 43
(634 Views)

Well said Yamaeda.

 

[RANT ON]

 

As everyone knows, I'm on the "bad Local" camp.

I started off being an abuser of Locals.  Heck..  I abused them so much that my nick should have been IluvLocals..

Locals looks nice, no wires to get your attention, makes your diagram nice & clean..  You run the software and it always works..

 

and then reality strikes.. 

 

People do not intend to abuse locals, it just happens.  Like drinking a glass of wine.  Humm... tastes really good.  Let's have it with cheeze..  And have 2 glasses, then the whole bottle.

Nothing wrong with wine. 

 

Nothing wrong with Locals.  But without noticing it, it gets abused.  It's just one more local.

 

That (using Locals) may be fine & dandy..  Code works.. 

Then you're in the other shoe.  You're the contractor fixing someone else's code that have no documentation, 100's of Sequence frames (Stacked Sequences) all full of Locals.

And they want you to fix the software in less than a day.  You spend your day explaining why it will take longer...  because of Local Variable abuse..

 

Just look at the length of this thread..  How can you on one hand say that Locals are nice and sweet and there is nothing wrong with them, and on the other hand state that they can become a nightmare if they are abused?  How do you explain that to a customer in less than 5 minutes?  How do you explain that it is MUCH faster to write the entire code from scratch? And that the code will be 1000% (actually more) faster than the original code?  How do you explain that looking for the bug when a single object (control) has over 100 Locals!!!  Oh yes..  over 100 Locals.

 

We can all say Locals are fine and do as you please and roses smell good and the sun is shining and all is well in LaLaLand..

We can try to educate people of Local abuse..  And there is a section on race condition if you take the NI course(s).

But Local abuse continues, even with the warnings and the teaching.

 

I'll pretend not knowing anything about Locals and wish to use them.  Please convince me to avoid abuse by first saying that they are fine..  That the only problem is occasional abuse if I am not careful..  Of course I'll be careful...  I will carefully abuse Locals, not realizing that it is happening...

 

If people insist on using Locals after being warned of the possibility, then yes, maybe I should start a "Let's All Use Locals" thread to encourage their use. ...  and one day people will hate me for not convincing them otherwise...

 

So your hated for being in one camp (anti-Locals)...  and will be hated for being pro-Locals when they discover the reality..

 

Maybe I should be neutral..  Live & let be..

 

[RANT OFF]

0 Kudos
Message 43 of 43
(595 Views)