Names Default To Here( 1 );
Unqualified names in a script with the Names Default To Here mode turned on are private to that script. However, the names persist as long as the script persists, or as long as objects created by or holding the script are still active. We recommend that all production scripts start with Names Default To Here(1) unless there is a specific reason not to do so. When the script uses an unqualified name in this mode, that name is resolved in the local namespace.
To refer to global variables, scope the name specifically as a global variable (for example, ::global_name). To refer to columns in a data table, scope with name specifically as a data table column (for example, :column_name).
Note: Names Default To Here( 1 ) defines a mode for a particular script. It is not a global function. One script can have this mode turned on, while another script can have it turned off. The default setting is off.
Local() creates local scopes only in specific contexts within a script and cannot enclose a longer script with interacting functions, while Names Default To Here(1) creates a local scope for an entire script.
If you have simple scripting needs, Names Default To Here(1) might be sufficient.
The Names Default To Here() function determines how unqualified named variable references are resolved. Explicitly scoping a variable using here:var_name always works, whether Names Default To Here() is on or off. See Scoped Names for details about here and other scopes.
Enabling the Names Default To Here mode associates a scope called Here with an executing script. The Here scope contains all of the unqualified named variables that are created when they are the target of an assignment (as an L-value). In JMP 8 and earlier, these variables normally would have been placed in the Global scope. Using a Here scope keeps variables in multiple executing scripts separate from each other, avoiding name collisions and simplifying the scripting and management of variable name collisions. You can still share information using the Global scope.
Run this example script one line at a time to see how the Names Default To Here() function changes the resolution of variable names.
a = 1;
Names Default To Here( 1 );
a = 5;
Show( global:a, a, here:a );
global:a = 1;
a = 5;
here:a = 5;
2.
Run the second line to turn on the Names Default To Here mode.
3.
Run the third line to create a new variable named a in the local space that holds the value 5. This line does not change the value assigned to the global variable a.
The unqualified a is resolved to here:a. If Names Default To Here() were not on, a would be resolved to the global variable named a.
Note that if you use ::a instead of global:a in the Show() function, your output is a little different:
Show(::a, a, here:a);
a = 1;
a = 5;
here:a = 5;
You have two scripts with the following definitions, andNames Default To Here() is turned off (the default condition) in both scripts.
a = 1; // script 1
Show( a );
 
a = 3; // script 2
Show( a );
a = 1
a = 3
3.
Run only the show(a); line in Script 1. The result is as follows:
a = 3
The log shows a = 3 because variable a is global, and was last modified by Script 2. This is the default behavior in JMP 9 and later, and it is the only possible behavior in JMP 8 and earlier.
4.
Now turn on Names Default To Here() in both scripts.
Names Default To Here(1);
Note: Names Default To Here() is local to a particular script. It is not a global setting.
a = 1
a = 3
7.
Run only the Show( a ); line in Script 1. The result is as follows:
a = 1
The log shows a = 1, because a copy of variable a is maintained for each script.

Help created on 9/19/2017