cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
nathan-clark
Level VI

Using new :Name() nomenclature with variable

I am really likeing the shift from :Name("column name") to :"column name"n, especially with how datatables can reference columns easier. But I am having trouble getting it to work when the column name is a variable.

dt = currentdatatable();
colName = "Column Name";

//old way works fine
Column(dt,colName) << set name("new column name");
//if it's not a variable it works
dt:"Column Name"n << set name("new column name");

//as a variable, the syntax is lost on me
dt:colName << set name("new column name") // nope
dt:colName||"n" << set name("new column name") // nope
dt:colName||n << set name("new column name") // nope

I am sure it's something simple ... but it's just not coming to me. The old way works fine so I can still keep scripting away, but this new method is much cleaner, and I'd like to use it everywhere

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Using new :Name() nomenclature with variable

Running on Windows 10 with JMP 15.2.1 I get the slightly different results

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
colName = "height";
Show(
	dt:Height[1],
	dt:Name( "height" )[1],
	dt:"Height"[1],
	dt:"Height"n[1],
	Column( dt, "Height" )[1],
	Column( dt, colName )[1],
	dt:colName[1]
);

dt:colName << set name( "New Column Name" );

Which returns

dt:Height[1] = 59;
dt:height[1] = 59;
dt:Height[1] = 59;
dt:Height[1] = 59;
Column(dt, "Height")[1] = 59;
Column(dt, colName)[1] = 59;
dt:colName[1] = 59;
Scriptable[]

with the data table having the following names after the script was run

new.PNG

Jim

View solution in original post

6 REPLIES 6
txnelson
Super User

Re: Using new :Name() nomenclature with variable

Running on Windows 10 with JMP 15.2.1 I get the slightly different results

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
colName = "height";
Show(
	dt:Height[1],
	dt:Name( "height" )[1],
	dt:"Height"[1],
	dt:"Height"n[1],
	Column( dt, "Height" )[1],
	Column( dt, colName )[1],
	dt:colName[1]
);

dt:colName << set name( "New Column Name" );

Which returns

dt:Height[1] = 59;
dt:height[1] = 59;
dt:Height[1] = 59;
dt:Height[1] = 59;
Column(dt, "Height")[1] = 59;
Column(dt, colName)[1] = 59;
dt:colName[1] = 59;
Scriptable[]

with the data table having the following names after the script was run

new.PNG

Jim
Jeff_Perkinson
Community Manager Community Manager

Re: Using new :Name() nomenclature with variable

I believe that the ""n construction is only intended for when you have need to use a character literal in the statement itself. So, it's not necessary to try to get the ",n" appended to it.

 

As for your testing this works for me:

 

dt = open("$SAMPLE_DATA/Big Class.jmp");

colName = "height";

dt:colName << set name("new column name");

 

 

-Jeff
txnelson
Super User

Re: Using new :Name() nomenclature with variable

Jeff,
I have done multiple searches in an effort to find the documentation on ""n documentation. Do you have the specific reference on it?
Jim
jthi
Super User

Re: Using new :Name() nomenclature with variable

After some googling figured out at least one place where I had seen that syntax before:

Automating the Data Curation Workflow (2020-US-45MP-620) 

 

which provides link to here:

JMP16.0 - JSL Syntax Guide - Names 

-Jarmo
nathan-clark
Level VI

Re: Using new :Name() nomenclature with variable

Thanks @txnelson and @Jeff_Perkinson ... That is definitely a simple fix

I feel I ran into troubles with that a while ago and never thought to try it again!

hogi
Level XII

Re: Using new :Name() nomenclature with variable

When was  the :columnName syntax introduced?
Is there further documentation why the same syntax was used for a) the Column object and b) the "As Column" reference, e.g. inside a formula?

 

Why does Name Expr (As Column()) return the :column Name thing - which again can be used for both purposes?