« FileMaker developer m… | Home | MBS FileMaker Plugin,… »

The power of global variables

As you may know we have global variables via plugin functions available in FileMaker.
While normal $ variables expire at the end of the script and $$ variables are tight to the current file, the plugin offers true global variables for all files (or when none is open). There is actually a feature request for $$$ variables: $$$Variable. So you can put a value in a variable and later pick it, even after a file changed. Some developers use this for login. The user starts the solution with one database file which performs some setup things and sets a few global variables, e.g. with the current user name and some permission settings. For example whether user is admin or debugging is enabled. Now in other files, they can check the variables and do things depending on the values.

To set a global variable, you call FM.VariableSet. To query it later you can use FM.VariableGet. If you like to know if a variable exists, you can query FM.VariableExists or check the list returned by FM.VariableList. To clear a variable you can cal FM.VariableClear.

On a server the global variables are in memory for all scripts run on server. So if one script sets a value, another script can read it. And that works even for different users. This way you can pass values from one client to other by performing scripts on server.

As you may know we store native values in those variables and our dictionary functions. This allows to store container or date values without converting them to text in-between.

Our dictionary functions allow you to have assoziative arrays in memory where you can lookup values based on a key value. Typically the keys are numbers or text and the value can be anything. For example you can load zip codes into a dictionary and later look them up quickly. The lookup is by using a hash table, so it's quicker than a database lookup.
09 06 16 - 10:06
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.