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