local tCurrentValue

Moderators: heatherlaine, Klaus, FourthWorld, kevinmiller

Post Reply
dimen426GA1Hmj
Posts: 16
Joined: Thu Dec 08, 2011 12:20 pm

local tCurrentValue

Post by dimen426GA1Hmj » Thu Aug 04, 2016 9:59 am

I tried removing the line in the percentPressed command script “local tCurrentValue” and the program executed just fine. My question is, was this line added as part of “good programming practice” or is there some practical reason for adding this code. For a newbie all I see is one additional line of code which I can do away with, making the code more efficient...or is it? When would you recommend adding the local variable and when would you not have to. Why would it make sense to add this to this particular script and this particular app now that I don't see any difference in the result.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4504
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: local tCurrentValue

Post by jacque » Thu Aug 04, 2016 5:51 pm

It's required if you are running with explicit variables turned on, which helps catch some typos in scripts. In some circles it's considered good programming practice as well, especially by those coming from other languages where it's required. I never debug with explicit variables so I don't include the declarations. It's mostly a matter of personal preference though it has been known to cause religious wars occasionally.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Calculator”