NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Knight of NI
Ray.R
Posts: 10,165

Why some people say Local Variables are bad...

[ Edited ]
There was a discussion in one thread where there seemed to be 2 camps.  One insisting that Locals were okay... and they are as long as they are carefully utilised, and the other saying that it is better to stay away from Locals, because most people abuse them considerably.
 
This thread is to tally all examples posted on this forum where Locals are either abused, misused, or caused headaches..  A Rube Goldberg cousin dedicated to Locals..  and the occasional Globals.. 
 
Please post examples and links.  
.
(starting to) See Life in a brand new way...

b* ^ )
Knight of NI
Ray.R
Posts: 10,165

Re: Why some people say Local Variables are bad...

Let's start with this first example.

Thanks to smercurio for posting this reply.

 

.
(starting to) See Life in a brand new way...

b* ^ )
Trusted Enthusiast
Posts: 2,687

Re: Why some people say Local Variables are bad...

Trusted Enthusiast
Posts: 2,687
0 Kudos

Re: Why some people say Local Variables are bad...

Dear JLV,

shall we post 'global' headaches also :smileysurprised: ???? :smileywink:

Thanks,

Mathan

Trusted Enthusiast
Posts: 2,687
0 Kudos

Re: Why some people say Local Variables are bad...

Here is a nice tutorial.... njoy

Thanks,

Mathan

Knight of NI
Ray.R
Posts: 10,165

Re: Why some people say Local Variables are bad...

Reverse programming (right-to-left) can be even more confusing with Locals!

See this link.

Mathan, yes Globals are okay :smileywink:

.
(starting to) See Life in a brand new way...

b* ^ )
Knight of NI
Ray.R
Posts: 10,165

Re: Why some people say Local Variables are bad...

[ Edited ]

Something seen often... Using Locals to write to itself: 

And of course, there is a race condition in (C); values in the case structure vs out.



Message Edited by JoeLabView on 05-22-2008 12:30 PM
.
(starting to) See Life in a brand new way...

b* ^ )
Knight of NI
Ray.R
Posts: 10,165

Re: Why some people say Local Variables are bad...

Example of why 18 frame stacked sequence with frames linked via sequence locals and local variables is a nightmare for code maintenance:

Discussed here

.
(starting to) See Life in a brand new way...

b* ^ )
Knight of NI
Ray.R
Posts: 10,165

Re: Why some people say Local Variables are bad...

And we're off to the races: (from http://forums.ni.com/ni/board/message?board.id=170&thread.id=285760)

.
(starting to) See Life in a brand new way...

b* ^ )
Knight of NI
Ray.R
Posts: 10,165

Re: Why some people say Local Variables are bad...

 
.
(starting to) See Life in a brand new way...

b* ^ )
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page