JMP interprets object names using name resolution. The following rules are applied sequentially to unscoped names:
1.
|
If the variable is followed by a pair of parentheses ( ), look it up as a function.
|
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.
|
7.
|
Look the variable up in the current scope and its parent scope. Repeat until the Here scope is encountered.
|
8.
|
Look the variable up as a variable in the Here scope.
|
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.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Show( :weight << Get As Matrix ); // weight resolves to a column name
Close( dt, NoSave );
Show( :weight << Get As Matrix ); // weight cannot be resolved
/* Reopen the data table */
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Show( :weight << Get As Matrix ); // weight resolves to a column name
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = Column( dt, 5); // col is Column( "weight" );
Close( dt, NoSave );
/* Reopen the data table */
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Show( col << Get As Matrix ); // The reference to the first data table no longer exists.