JSL rename columns based on user selectionI am trying to rename column names based on user selection of file. But, I am having trouble renaming the columns. I have added my code, the set name doesn't work for renaming. I think I am doing something wrong. Can anyone please let me know about this?
Clear Log();
dt1_dir = Pick Directory( "Select directory for data table 1" );
dt1_Name = Pick File( "Select data file 1", dt1_dir, {"JMP Files|jmp;jsl;jrn", "All Files|*"}, 1, 0, 0 );
Show( dt1_Name );
dt = Open( dt1_Name );
Show( dt );
dt<< bring window to front;
box = column dialog(
a=collist("BDATE", MAX col(1), min col(1),DataType ("Numeric")),
b=collist("SHIPDATE", MAX col(1), min col(1), DataType ("Numeric")),
c=collist("BUY Date", MAX col(1),min col(1), DataType ("Numeric")),
);
box["a"] << set name("build date")
box["b"] << set name("shipping date")
box["c"] << set name("buy date")AnalyticsData TableScriptingWindowsRe: JSL rename columns based on user selectionHi @shasha_2 ,
I'm not 100% sure of what you want to do and how you intend to use the Column Dialog() command, but the script below will do what you want. It also gives you a lot more flexibility in terms of what options you have in your new window, etc. If you want to make the window modal, just add <
Names Default To Here( 1 );
bwidth = 100;
dt = New Table("test",
Add Rows(3),
New Column("Col 1", Continuous),
New Column("Col 2", Continuous),
New Column("Col 3", Continuous)
);
dt << bring window to front;
box_win = New Window( "Select Columns",
H List Box(
Panel Box( "Select Columns", ColListData = Col List Box( dt, All, Grouped, width( bwidth ), nLines( 5 ) ) ),
V List Box(
Panel Box( "Case Selected Columns Into Roles",
Lineup Box( N Col( 2 ), Spacing( 3 ),
Button Box( "BDATE", colLista << Append( ColListData << Get Selected ) ),
ColLista = Col List Box( width( bwidth ), N Lines( 1 ), Max Items( 1 ), Min Items( 1 ), <<SET data="https://community.jmp.com/" type=""></SET>Hope this helps,
DS
Re: JSL rename columns based on user selectionbox["a"]
returns a JMP List,
{:NPN1}
not a string or an expression. Therefore you need to properly extract the element from the list, and present it back to JSL as a column
as column((box["a"])[1]) << Set Name( :build date" );
Here are the modification you need to make to make the name changes
as column((box["a"])[1]) << set name( "build date" );
as column((box["b"])[1]) << set name( "shipping date" );
as column((box["c"])[1]) << set name( "buy date" );