Local mutiny .... (=^‥^=)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Local mutiny .... (=^‥^=)

Post by jacque » Sat Jul 08, 2017 4:05 pm

MaxV wrote:Mariasole, consider this:
local/global variable = bad
custom properties = good


That's a broad generalization. It depends on usage. Custom properties are very useful for permanent storage but they need to be managed carefully to avoid mistakes between sessions when used as transient storage. Variables are managed by the engine and are cleared automatically when no longer needed. In almost all cases, a script local provides the same functionality without the need to manage existence and content.

I speak from embarrassing experience. I now go out of my way to avoid transient custom properties. I use them for permanent entries that are part of the stack, never as a substitute for variables.

Variables and custom properties are meant for different uses. While it is possible to use properties as temporary storage, I'd advise against it. There are better ways that won't cause unexpected problems later.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Local mutiny .... (=^‥^=)

Post by jacque » Sat Jul 08, 2017 4:15 pm

But I thought that script local variables also lasted only while the script has active handlers. Declaring a local variable in the script has made it more like a global variable. I might be wrong, but this is not how I understood script local variables to behave, I didn't think script local variables maintained persistence, unless the checkbox in the Preferences under "Script Editor" for "Variable Preservation" is checked, but my system (Windows 10, LiveCode 9, DP-7) is showing persistence whether or not the checkbox is set in Preferences.
Script locals always persistent in normal operation. The checkbox in preferences controls whether they retain their values after a compile. In MetaCard they did not, so any edited script had to reset all it's locals after every change. Adding persistence was one of the first things Mark Waddingham did after taking up the reins. It bugged him as much as anyone else. He added the checkbox for those who wanted to retain the old behavior.

But when you aren't compiling scripts, the checkbox does nothing.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Re: Local mutiny .... (=^‥^=)

Post by Mariasole » Thu Jul 13, 2017 9:20 am

Thanks brother SparkOut,
You made clear to me the behavior of the variables I had never thought of! :D

Thank you sister Jacque!
Read your posts was how to sit in listening to a lectio magistralis! 8)

Thank you all... really!

Mariasole
(=^‥^=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

Post Reply