FileMaker Variables – Local vs Global Explained
A NICELY WRITTEN post on variables from Dwayne Wright. Some topics don’t change much over the years, and this one stands the test of time:
A local variable is defined by adding a single dollar sign in its name such as $InvoiceNumber, $ClientID or $Counter. A local variable will store it’s information within the script / calculation while that script / calculation is running. After it is finished in it’s execution, the defined local variable will have no value. An advantage of this is like a disposable lighter. When you are done, you throw it away because you never intend to refill it.
A global variable is defined by adding a two dollar sign characters in it’s name such as $$InvoiceRange, $$Array or $$UserPrefs. A global variable will store it’s information within the entire file while the file is open. This way it can be used across scripts or even in-between times that scripts are called upon.
Variables–local or global–are one of a programmers best friends. But they must be used properly. For example, local variables won’t carry over to another script, but that doesn’t necessarily stop them from existing when a subscript is run. Assuming the subscript doesn’t terminate the parent script, local variables will still be there when you return to the parent.
Global variables exist until the user session ends or until cleared by the developers actions. But you don’t want to clutter up memory by not clearing them when they are not needed, or have then carrying the wrong value at the start of a process. Good programming technique requires choosing the right type to use and managing memory space properly to prevent such problems.
Follow the link and read the whole blog post.
More…Dwayne Wright PMP, PMI-ACP, CSM – FileMaker Thoughts – FileMaker Memory Variables Explored.