我正在尋找一種從剪貼板中的列列表填充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 />