JSL 錯誤:訪問或評估“For”時參數不足你好,
我是 JSL 腳本編寫的初學者。 我需要有關以下錯誤的幫助。
“訪問或評估‘For’時沒有足夠的參數”
在下面的代碼中,我嘗試刪除列名稱中包含某些字符串的列。 我不確定我在哪裡犯了錯誤。
dt = Current Data Table();
col_list = dt << get column names(string);
for(i = 1; i>= N Items (col_list), i++,
If(
Contains(col_list[i], "MTR") | Contains(col_list[i], "AUTO") | Contains(col_list[i], "ProcessCon") | Contains(col_list[i], "Macro") | Contains(col_list[i], "OTH_SP") ),
Remove from(col_list, i)
)
);
dt << delete columns( col_list );
請告訴我。 謝謝。
回复:JSL 錯誤在訪問或評估“For”時沒有足夠的參數我能夠解決這個問題,下面的代碼可以幫助我根據列名稱刪除列。
Clear Log();
dt = Current Data Table();
col_list = dt << get column names;
For( c = N Cols( dt ), c >= 1, c--,
If(
Contains( col_list[c], "MTR" ) | Contains( col_list[c], "AUTO" ) | Contains( col_list[c], "ProcessCon" )
| Contains( col_list[c], "Macro" ),
dt << deleteColumn( c )
);
);
回复:JSL 錯誤在訪問或評估“For”時沒有足夠的參數嗨傑夫,
謝謝。 這樣就消除了錯誤。 但是,我肯定犯了一個邏輯錯誤。 我的代碼刪除了數據表中的所有列。
也許,我在刪除列時犯了一個錯誤?
我可以寫以下內容,而不是“從 (col_list, i) 中刪除”嗎?
dt<< 刪除列(col_list[i]); ?
我不確定語法。 但我的目標是刪除列名稱中包含“MTR”或“ProcessCon”等的所有列。
請告訴我。
回复:JSL 錯誤在訪問或評估“For”時沒有足夠的參數第一個參數後面有一個分號 (;),而不是逗號 (,)。
您還有一個額外的右括號。
它應該是:
dt = Current Data Table();
col_list = dt << get column names( string );
For( i = 1, i >= N Items( col_list ), i++,
//________^
//comma here, no semi-colon
If(
Contains( col_list[i], "MTR" ) | Contains( col_list[i], "AUTO" ) |
Contains( col_list[i], "ProcessCon" ) | Contains( col_list[i], "Macro" ) |
Contains( col_list[i], "OTH_SP" )
),
Remove From( col_list, i )
//)
//don't need close parentheses above
);
dt << delete columns( col_list );