for循環中的問題大家好,我無法弄清楚為什麼這個 for 循環公式不起作用。 如果單位是及時的,它只是創建一個新列,然後將其轉換為小時。 樣本數據也附上。 謝謝。
ColNames = dt << get column names( string, Numeric, character, continuous, Nominal );
N Items( ColNames );
For( i = 1, i <= N Items( ColNames ), i++,
If( Ends With( ColNames[i], "(secs)" ),
New Column (Concat(ColNames[i], "_to_", "Hr"), Formula(AS Column(ColNames[i])/3600) ),
Ends With( ColNames[i], "(min)" ),
New Column (Concat(ColNames[i], "_to_", "Hr"), Formula(AS Column(ColNames[i])/60) ),)
);
Wait( 0 );
腳本回复:for循環中的問題問題是公式元素不解析呈現的公式,然後將生成的代碼放入公式中。因此,呈現給公式元素的內容必須正是公式所需的 JSL。下面是你的jsl的返工
Names Default To Here( 1 );
dt = Current Data Table();
ColNames = dt << get column names( string, Numeric, character, continuous, Nominal );
//N Items( ColNames );
For( i = 1, i <= N Items( ColNames ), i++,
If(
Ends With( ColNames[i], "(secs)" ),
New Column( Concat( ColNames[i], "_to_", "Hr" ),
Formula( Eval( Parse( ":\!"" || ColNames[i] || "\!"n / 3600" ) ) )
),
Ends With( ColNames[i], "(min)" ),
New Column( Concat( ColNames[i], "_to_", "Hr" ),
Formula( Eval( Parse( ":\!"" || ColNames[i] || "\!"n / 60" ) ) )
),
)
);回覆:for循環中的問題謝謝你吉姆。它正在工作。
回覆:for 循環中的問題感謝 Erratic,它正在發揮作用。這兩種解決方案(來自 Jim 和您自己)都運作良好。但是您提供的解決方案 - 我從未見過(JSL Code())。謝謝。