用戶定義函數:如何將輸出變量值傳遞給另一個變量你好,我正在編寫一個驗證用戶輸入的代碼。 用戶輸入是兩個列表,B 和 C。 輸出是列表 A,其中包含 B 和 C 中包含的所有項目。 這是代碼:
//CHECK IF USER INPUT MAKES SENSE
Caption("Checking input data...");
col_name_list = dt << get column names( string );
//Check if there are duplicate or missing inputs
//Create a User-Defined Function
ColCheck=Function({main, second}, {duplicate},
(duplicate={}; Show (duplicate);
For (i=1, i<=Nitems(main), i++,
//Check if there are missing columns from user input
If ( !Contains( col_name_list, main[i] ),
Write("WARNING! Column " || main[i] ||" does not exists. Creating data column.");
Caption("WARNING! Column " || main[i] ||" does not exists. Creating data column.");
Wait( 1 );
script1 = "dt<<NEW column=""></NEW>這是輸出:
A = {};
duplicate = {};
duplicate = {"two"};
duplicate = {"two", "three"};
A = .;從“重複”變量的值可以看出,這些函數是有效的。問題是這樣的:重複的內容無法傳遞給變量“A”。 我的代碼有什麼問題嗎?
回复:用戶定義函數:如何將輸出變量值傳遞給另一個變量謝謝吉姆。 現在正在工作。
最好的,
夏伊拉
回复:用戶定義函數:如何將輸出變量值傳遞給另一個變量從 JMP 函數或格式傳回的內容是最後處理的值,因此如果將“重複”添加為最後一項,效果會很好。
ColCheck = Function( {main, second},
{duplicate},
duplicate = {};
Show( duplicate );
For( i = 1, i <= N Items( main ), i++,
//Check if there are missing columns from user input
If( !Contains( col_name_list, main[i] ),
Write( "WARNING! Column " || main[i] || " does not exists. Creating data column." );
Caption( "WARNING! Column " || main[i] || " does not exists. Creating data column." );
Wait( 1 );
script1 = "dt<<NEW column=""></NEW>