Hi JMP community,
After 2 days of learning, I have finally produced a JSL script that performs the column name change operation I was looking for. However, considering the rather laborious process to get to this result, I suspect that I may have used sub-optimal approaches. Therefore, I'm looking for ways to clean up this script.
Names Default To Here( 1 );
dt = Current Data Table();
src=.;
trg = .;
sfx = "";
pfx = "";
n = 0;
m = 0;
win = New Window (
" WARNING ",
<< Modal,
Text Box (" It is recommended that you save your table before proceeding "),
Button Box (
"SAVE NOW",
dt << Save("");
),
);
cd = Column Dialog(
cl1 = ColList( "SOURCES", Min Col (1)),
cl2 = ColList( "TARGETS", Min Col (1)),
Line Up( 2,
Text Box( "Prefix" ), ex = EditText( "P_" ),
Text Box( "Suffix" ), ey = EditText( "_S" )
),
);
src=cd[1];
srcx = right (src,length (src)); // I'm not sure how this works but without this the script fails
n = N items (srcx);
trg = cd[2];
trgx = right (trg,length (trg)); // I'm not sure how this works but without this the script fails
m = N items (trgx);
pfx = cd [4];
sfx = cd [6];
If (n == m,
st = "";
For (i=1, i <= m, i++,
scol = srcx [i] << Get Name;
st = pfx || scol || sfx;
trgx [i] << Set Name (st);
);
,Stop());
Your feedback would be greatly appreciated.
Cheers,
TS
Thierry R. Sornasse