将报告输出保存到数据表中通常会创建很长的列名,这在后续分析中变得很麻烦。 这是一个愚蠢的小脚本,用于从选定列的名称中替换/删除文本。
使用方法:选择要修改的列,运行脚本,输入需要修改的文本(包括空格),然后输入要修改的文本(同样包括空格,留空替换为空)。
显然,如果没有打开的数据表,脚本什么都不做。 如果没有选择任何列,即没有任何列被标识为需要更改,则脚本当前不执行任何操作,但可以添加选择列的提示。
更新:首先选择的列名包含在文本框中,以便更容易指示要查找的文本
Here is the updated script (the only change was to add << Return Result, so the Text Box would return what was entered (not sure why it worked before):
//!
// Initialize
Names Default to Here( 1 );
Clear Log();
dt = Current Data Table( );
// Stop the script if no open data tables
If( Is Empty( dt ), Stop());
cols = dt << Get Selected Columns( );
// Stop the script if no columns selected
If( N Items( cols ) == 0, Stop());
// Prompt user for text to remove
eBox1 = New Window(
"Find",
<< Modal,
<< Return Result,
Text Box(
"What text should be removed from the column names
(including spaces, i.e. delete the text you want to keep)?",
Justify Text ("Center"),
Set Width(500)
),
Spacer Box( Size( 12.5, 12.5 ) ),
editBox = Text Edit Box(cols[1] << Get Name()),
editBox << Set Width(500),
Spacer Box( Size( 12.5, 12.5 ) ),
H List Box( Button Box( "OK",
remove this = editBox << Get Text;
// Stop the script if the user doesn't enter any text
If( remove this == "", Stop())
),
Button Box( "Cancel" ),
<< Horizontal Alignment( "Center" )
)
);
// Stop the script if the user hits the cancel button
If( eBox1["Button"] == -1, Print("Canceled"); Stop());
// Prompt user for text to replace
eBox2 = New Window(
"Replace With",
<< Modal,
<< Return Result,
Text Box(
"What should the text be replaced with
(including spaces, or leave blank)?",
Justify Text ("Center"),
Set Width(300)
),
Spacer Box( Size( 12.5, 12.5 ) ),
editBox2 = Text Edit Box(),
editBox2 << Set Width(300),
Spacer Box( Size( 12.5, 12.5 ) ),
H List Box( Button Box( "OK",
replace with = editBox2 << Get Text
),
Button Box( "Cancel" ),
<< Horizontal Alignment( "Center" )
)
);
// Stop the script if the user hits the cancel button
If( eBox2["Button"] == -1, Print("Cancled"); Stop());
// Loop through the columns adding the tag to the end of the existing name
For( i = 1, i <= N Items( cols ), i++,
cols[ i ] << set name( munger(cols[ i ] << get name, 1, remove this, replace with))
); // Next column
// End抱歉这么久才回复,我忘了我把这个贴在这里了。 是的,它可以修复。 - 完毕
感谢您的分享。
但是这个很棒的插件不能用在 JMP16 上。
它显示错误消息:删除对象引用:编辑框<<在访问或评估“胶水”时获取下一个
有什么解决办法吗?