该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


Using scoping operators is an easy way to help JMP resolve ambiguous names (for example, when a name refers to both a variable and a column name).
In the following example, the prefix double-colon operator (::) identifies z as a global variable. The single-colon prefix operator (:) identifies x and y as column names.
提示:The Names Default to Here(1) function also affects name resolution. See “Names Default To Here and Global Variables” on page 254 in the “Programming Methods” chapter for details.
As Column(dt, name)
Forces name to be evaluated as a data table column. The optional data table reference argument, dt, sets the current data table. See Scoped Column Names for examples.
Forces name to be evaluated as a global variable.
1.
The prefix colon (:) means that the name refers to a table column or table variable only, never a global variable. The prefix colon refers to the current data table context.
2.
The infix colon (:) operator extends this notion by using a data table reference to specify which data table has the column. This is particularly important when multiple data tables are referenced in a script.
In the following example, the dt variable sets the data table reference to Big Class.jmp. The infix colon separates the data table reference and age column.
As Column() achieves the same results:
The Column function can also identify a column. For Big Class.jmp, the following expressions all refer to age, the second column in the table:
When you run a script that includes a column and variable with the same name, an Invalid Row Number error occurs. To prevent this problem, use unique column and variable names, or scope the names as follows:
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Students.jmp" );
::age = dt1:age << Get As Matrix;
or the name is subscripted (for example, the subscript [1] in weight[1] selects the first value in the weight column).
Specify the row number with the Row() function. In the following example, the row is set to 3. The height in that row is divided by the weight, and the result is assigned to the ratio global variable.
Row() = 3;
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "ratio" );
For Each Row( :ratio = height / weight );