Do $$Variables stick around forever unless modified in a subsequent script?
Does either affect other users on a server?
Other users are not affected by either variable, they are user specific. $ is a script variable, and $$ is a file variable. To pass a variable between scripts you need to use the $$ variable. It is necessary to null the $$ variable out to preclude the next new script you run from using it by accident, unless that is your intention. When you close the file the $$ variable is cleared. If you want a variable to stick around forever, and be useable by other users, put the value in a table with one record and use a constant relation to access that table.
jimhoyt wrote:To pass a variable between scripts you need to use the $$ variable. It is necessary to null the $$ variable out to preclude the next new script you run from using it by accident, unless that is your intention.
To pass a variable between scripts you need to use the $$ variable. It is necessary to null the $$ variable out to preclude the next new script you run from using it by accident, unless that is your intention.
There is not really a need to use $$-variable to pass variables between scripts. Actually because they are "global" they are handy when you don't have a script running and you need the data in the variable later on.
It makes more sense to start/call a script using the ScriptParameter. You can for example send "$var1=\"MyText\";$var2=15" as a ScriptParameter and use
Set Variable [$result; Value:Evaluate ( "Let([" & Get ( ScriptParameter ) & "];1)" ) ]
to load the variables in that script as local variables. If the parameter fro some reason is invalid the $result will contain a "?" in stead of "1".
This way of using script variables and parameters is pretty rudimentary but works very well. Lots of people have adopted this method and have built really nice methods to make this easier and less faulty. To see more about this, you can have a look at these locations:
FileMaker Pro 15 Help
Data Serialization (Let Notation) - Best Practices - FileMaker Coding Standards
I am not saying you cannot use $$variables to pass around script variables, because you can, only that there are better ways to do it.
$variable is more limited, but only the $$variable can be shown on a layout as a Merge Variable.
All Variables Should Be Global... Or Not. - Soliant Consulting
Some of the uses of $$variables have not been mention in this thread.
Bevery mentioned using them in <<$$Variable>> on a layout and there are many more places where they work.
For instance in a multi-language db I use almost 300 $$variables as text in buttons and layout objects. Changing the language preference changes all of these values.
In FileMaker 15 I can name the button $$close or $$print, etc. and these button names all change almost instantly when my script runs.
Creating a text label <<$$FirstName>> changes with the language preference to First Name, etc.
So how variables are used should be considered both from utiility and security.
List('*';"*";"*".....;"*") can be used to pass parameters just make sure none are empty. Or a repeating variable. I once saw where someone was bogged down in parsing a parameter using "|" and position and etc. and mentioned that using a repeating variable instead would simplify everything.
Also note there are 'types' of variable use:
Global Never Modify
Retrieving data ...