<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
是否有人有一個 JSL 腳本,可以將一個數據表中的列屬性複製到另一個數據表中的“同名”列?
該錯誤消息意味著您的新公式列涉及同一表中不存在的一個或多個列。 您確定計算公式值所需的所有列都在新表中嗎?
你好,
我找到了這篇相對較舊的帖子,並嘗試將解決方案應用於我正在執行的腳本,但我在調試器中收到以下錯誤消息:
“公式引用了另一個表中的列或表變量,但無法找到重新映射到此表的方法”
我的情況有點簡單,因為我只是嘗試複製單個列的屬性
colProps = Column( dt, "Response Predictor" ) << Get Column Properties;
Column( dtparms, "Formula" ) << Add Column Properties( colProps );
知道我做錯了什麼嗎?
約翰
感謝您的幫助。 這就成功了! 我的新表將始終是“主表”的子集,並且“try”語句確實解決了這個問題。
樓
“快速修復”:將循環的第二行放入其中嘗試()以避免新表中缺少任何列時出現錯誤(此處列順序不重要)。
Try( Column( nt, colNames[i] ) << Add Column Properties( colProps ) );
感謝您的幫助。 我試圖迭代這兩個表,但沒有正確的命令。
看起來只要兩個表具有相同的列、相同的順序就可以工作。 它是否正確?
樓
盧,
下面演示瞭如何將列屬性從一個表複製到另一個表(假設列名稱相同)。
dt = Open( "$SAMPLE_DATA\Tiretread.jmp" );
colNames = dt << Get Column Names( String );
nt = New Table( "New Tires",
New Column( "ABRASION", Numeric, Continuous, Format( "Best", 10 ) ),
New Column( "MODULUS", Numeric, Continuous, Format( "Best", 10 ) ),
New Column( "ELONG", Numeric, Continuous, Format( "Best", 10 ) ),
New Column( "HARDNESS", Numeric, Continuous, Format( "Best", 10 ) ),
New Column( "SILICA", Numeric, Continuous, ),
New Column( "SILANE", Numeric, Continuous, Format( "Best", 10 ) ),
New Column( "SULFUR", Numeric, Continuous, Format( "Best", 10 ) ),
New Column( "Pred Formula ABRASION", Numeric, Continuous, Format( "Best", 10 ) ),
New Column( "Pred Formula MODULUS", Numeric, Continuous, Format( "Best", 10 ) ),
New Column( "Pred Formula ELONG", Numeric, Continuous, Format( "Best", 10 ) ),
New Column( "Pred Formula HARDNESS", Numeric, Continuous, Format( "Best", 10 ) )
);
For( i = 1, i <= N Cols( dt ), i++,
colProps = Column( dt, colNames ) << Get Column Properties;
Column( nt, colNames ) << Add Column Properties( colProps );
);