- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Using new :Name() nomenclature with variable
I have done multiple searches in an effort to find the documentation on ""n documentation. Do you have the specific reference on it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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?