The Names Default To Here() function. If you have simple scripting needs, this single command might be sufficient. See Names Default To Here.
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.
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:
You have two scripts with the following definitions, and Names Default To Here() is turned off (the default condition) in both scripts.
3.
Run only the show(a); line in Script 1. The result is as follows:
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.
Note: Names Default To Here() is local to a particular script. It is not a global setting.
7.
Run only the show(a); line in Script 1. The result is as follows:
The log shows a = 1, because a copy of variable a is maintained for each script.
Specify where a name is to be resolved by using a scope in the form scope:name where scope indicates how to resolve the name. For example, here:name indicates that the name should be resolved locally. Using the Names Default To Here mode, here:name is equivalent to name. The scope instructs how to look up the name.
Scope can be a resolution rule. For example, here:x means that x should be resolved to a name that is local to the script. Global:x means that x should be resolved to a global name.
Scope can be a namespace reference variable. For example. ref:a means that a should be resolved within the namespace that ref refers to.
Scope can be a data table reference to look up names as column names. For example, dt:height means that height should be resolved as a column in the data table that dt references.
Scope can be the name of a namespace that you created. For example, myNamespace:b where myNamespace is a namespace that you created. "myNamespace":b is equivalent. See Namespaces.
In the first script, the column name x is unscoped. the formula in the second column multiplies the value in column x by 100. In this case, The result is a column with the values 100, 200, and 300.
In the following script, the formula in column y assigns 500 to x and then adds 50 to x. Each cell in the column contains the value 550.
JMP built-in functions. For example, Builtin:Sqrt(). These names are shared throughout the JMP environment.
Provides a namespace block inside Names Default to Here(1). Local( {Default Local}, ) does not always work due to the lifetime of the local block, but Local Here() is persistent across the call.
This example uses the Window scope to pass information during execution. Explicitly scoping the variables x and y to this window ensures that JMP does not try to scope x and y in other contexts, such as a data table. The variables x and y are created and used solely inside the Window environment. The Window scope is similar to using Local(), but more useful because Local() is limited in the places that it can be used.
Example of Current Window Namespace
This example uses the Here scope to pass information between windows that are created by the same script. Scoping a variable using Here: is not dependent on turning Names Default To Here() on. The Here: scope is always available.
The Launcher window asks the user for two values. Those two values are passed to the Output window, which uses them to graph a function. The Launcher window scopes aBox and bBox to the window: essentially, those two variables (pointers to Number Edit Boxes) exist only in the Launcher window and are not available to the Output window. The values from those two boxes are then copied into variables that are scoped to Here, and so are available to both windows that are produced by this script.
Launcher and Output
A namespace is a collection of unique names and corresponding values. You can store references to namespaces in variables. Namespace names are global, because JMP has only one namespace map. Namespace references are variables like any other variable that references an object, so they must be unique within their scope or namespace. The members of a namespace are referenced with the : scoping operator, such as my_namespace:x to refer to the object that is named x within the namespace called my_namespace. See User-Defined Namespace Functions for details about creating and managing your own namespaces. Namespaces are especially useful for avoiding name collisions between different scripts.
Creates a new namespace called nsname (a string expression) and returns a reference to the namespace. All arguments are optional.
Nsname is the name of the namespace in the internal global list of namespace names. Nsname can be used as the prefix in a scoped variable. The function returns a reference to the namespace, and can also be used as the prefix in a scoped variable reference. If nsname is absent, the namespace is anonymous and is given a unique name created by JMP. Show Namespace() shows all namespaces and their names, whether assigned or anonymous.
Important: If you already have a namespace named nsname, it is replaced. This behavior means that while you are developing your script, you can make your changes and re-run the script without having to clear or delete your namespace. To avoid unintentional replacement, you can either use anonymous namespaces, or test to see whether a particular namespace already exists:
Note: Namespace() returns a reference to a namespace that already exists. It does not create a new namespace.
Returns 1 (true) if nsref is a namespace or 0 (false) otherwise.
As Scoped() is the function form of a scoped reference. The function returns a reference to the specified variable in the specified scope.
Returns 1 (true) if nsname exists in the list of global namespaces, or 0 (false) otherwise.
Namespace Messages defines the messages that are supported by user-defined namespace references.
Returns 1 or 0, depending on whether var_name exists within the namespace.
To delete variables in the namespace, use <<Remove. See the entry for <<Remove in this table.
Returns the unevaluated expression that var_name contains in this namespace.
Inserts into this namespace a variable named var_name that holds the expression expr.
The following are all equivalent references to a variable that is named b in the namespace that is named nsname that has a reference nsref:
There is also an option for the Include function (New Context) that creates a namespace that the included script runs in. This namespaces is an anonymous namespace and it is independent from the parent script’s namespace. For example,
See Includes for more information about the Include function.
There are a number of factors in resolving a named variable reference. Namespace References describes the named variable references that are resolved for specific situations.
If the Names Default To Here mode is on, JMP looks for the variable in these locations:
Local namespace2
Here namespace
If the Names Default To Here mode is off, JMP looks for the variable in these locations:
Local namespaceb
Here namespace
Global namespace
If the Names Default To Here mode is on, then JMP creates the variable in the Local namespaceb or in the Here namespace.
If the Names Default To Here mode is off, then JMP creates the variable in the Local namespaceb or in the Global namespace.
JMP looks for the variable in the encapsulating Context Box namespace contained in a New Window window.
JMP creates the variable in the encapsulating Context Box namespace contained in a New Window window.

1

2

A qualified named reference uses the : and :: operators to provide specific information about where a referenced variable resides, or where it is created. Examples of qualified named references include the following:
An unqualified named reference provides no explicit information to completely identify where a variable resides or where it is created. No scoping operator (: or ::) is specified in the reference. To change the behavior of JMP when resolving unqualified named variable references, use the Names Default To Here(1) function. For more details about variable name resolution, see the Rules for Name Resolution in JSL Building Blocks.
1.
2.
If the variable is prefixed by : scope operator or an explicit data table reference, look it up as a data table column or table variable.
3.
If the variable is prefixed by :: scope operator, look it up as a global variable.
4.
If the variable is an explicit scope reference (such as group:vowel), look it up in the user-defined group namespace.
5.
If the variable is in a Local or Parameter function, look it up as a local variable. If it is nested, repeat until a function call boundary is found.
10.
If Names Default to Here(1) is at the top of the script, stop looking. The scope is local.
If the variable is preceded by :: scope operator, create and use a global variable.
If Names Default to Here(0) is at the top of the script, create a global variable.
If Names Default to Here(1) is at the top of the script, create a Here namespace variable.