我正在寻找一种从剪贴板中的列列表填充 collistbox 的方法。我尝试了 getclipboard() 命令,但由于返回的列表不是列名列表,因此此方法失败。
作为背景,我从一个数据表中复制列名称列表(名称列在行中),并使用复制的列名称列表作为另一个数据表分析中的分析的输入。
如果我只是打开分析平台 (NN) 并右键单击 X 输入框,我可以粘贴列名称。


我希望这些条款显示在第二个框中:

因此,我将复制列名称并运行我的脚本,并且可以在可选框中选择列。
感谢您的任何想法!
效果非常好!
我已将您的代码添加到此中,我很高兴可以开始:
selCols = dt << Get selected Columns( String );
obj2=new window("Reponse Variable",
<<MODAL></MODAL>也许有一种更简单的方法,但我认为下面脚本中的变量 Clip_items 可以帮助您入门。这会获取剪贴板中的每一行并查找匹配的列。脚本的其余部分选择数据表中的那些列。我从菜单中运行此脚本作为加载项的一部分。
names default to here(1);
dt = current data table();
//Get list of columns in clipboard
clip_input = Get Clipboard();
clip = clip_input;
clip_items = {};
done = 0;
for( i = 1, done == 0 & i <= 10000, i++,
show(clip);
If (
N Items(Regex Match(clip,"[\!\r\!\n]")) == 0
,
if(
length(clip) > 0
,
Insert Into( clip_items, clip)
);
done = 1;
,
thisrow = Regex(clip,"(.+?)[\!\r\!\n]","\!\1");
if( length(thisrow) > 0, Insert Into( clip_items, thisrow) ) ;
clip = Regex(clip,"\!\n(.*)","\1");
);
);
if( i > 10000, throw("found more than 10000 variables"));
col_names = dt << Get Column Names( String );
For( i = 1, i <= N Items( col_names ), i++,
if( contains( clip_items, col_names[i] ),
Column( dt, i ) << Set Selected ( 1 );,
Column( dt, i ) << Set Selected( 0 );,
)
);<BR />