The easiest way to refer to a column is by its name. If you have a global variable and a column with the same name, to prevent ambiguity, scope the column name with the : prefix operator.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Row() = 5; // select row 5
dt:age = 19; // set the age in row 5 to 19
dt:name = "Sam"; // set the name in row 5 to Sam
dt:age[10] = 20; // set the value of age in row 10 to 20
Row() = 16; // select row 16
myGlobal = :age; // store the age as a variable
:age; // returns 14, the age in row 16
Show( :age ); // returns age = 14;
To get the value of a cell in a specific row, include the column name and row number. Both of the following examples return 13, the value of age in row 12 of Big Class.jmp:
:age[12];
myGlobal = :age[12];
To get a value in a data column reference, use Column() and As Column() to get the value in a data column reference. For more information, see Access Cell Values through Column References.
•
|
An empty subscript, such as :age[ ], refers to the current row.
|
•
|
Be careful that you are subscripting to a table row that exists. The default row number is zero, so statements like :name that refer to row zero generate an Invalid Row Number error.
|