JSL 脚本(重命名列)反馈:有效但我不确定为什么!嗨 JMP 社区,
经过2天的学习,我终于制作了一个执行我要找的列名更改操作的JSL脚本。 但是,考虑到获得此结果的过程相当费力,我怀疑我可能使用了次优方法。 因此,我正在寻找清理此脚本的方法。
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());非常感谢您的反馈。
干杯,
TS
回复:JSL 脚本(重命名列)反馈:有效但我不确定为什么!嗨女士,
感谢您的反馈,非常感谢
最好的,
TS回复:JSL 脚本(重命名列)反馈:有效但我不确定为什么!很好,你想学习 JSL。 真的很有用! 如果您有在 JMP 中交互式工作的经验,那么入门并不难。 许多 JSL 语法看起来合乎逻辑且直截了当。 然而,当然有一些古怪的东西,比如返回的列表列对话框 ()。
对于此任务,我可能会使用非模态 New Window() 作为控制面板。
以下是简化脚本的尝试,仍在使用列对话框. 我用评估列表()执行输出的一些赋值表达式列对话框,这消除了对额外变量的需要。
Names Default To Here(1);
dt = Current Data Table();
cd = Column Dialog(
src=ColList("SOURCES", Min Col(1)),
trg = ColList("TARGETS", Min Col(1)),
Line Up(2,
Text Box("Prefix"), pfx = EditText("P_"),
Text Box("Suffix"), sfx = EditText("_S")
)
);
Eval List(cd[[1 2 4 6]]); //Execute relevant assignments within list cd
Show(src, trg, pfx, sfx); // Just to confirm (can be deleted)
n = N Items(src);
m = N Items(trg);
For(i = 1, i <= Min(n, m), i++,
trg[i] << Set Name(pfx || (src[i] << get name) || sfx)
);