我正在嘗試創建一對腳本,第一個將列名和公式保存到列表中,第二個將通過使用命名空間並將它們應用於另一個數據表。 我相信我已經處理了基本命名空間概念,但是在應用屬性時遇到了問題。 任何幫助將非常感激。
腳本1:
clear symbols(); //for debug
Names Default to Here(1); //namespace declaration,create variables in local scope only
ns = New Namespace("outer");
dt = Current data table();
if(isEmpty(dt),
try(dt = Open(), Throw("No data table found"))
);
nc = nCol( dt );
ns:names = dt << Get Column Names();// get column names
print(ns:names);
ns:formulaList={};
For( i = 1, i < N Items(ns:names), i++,
col = Column(i);
ns:formulaList[i] = col << get Property( "Formula");
);
print (ns:formulaList);
ns <<LOCK></LOCK>
輸出:
{Col1,umn 2,Con 4,Column}
{Empty(),:Col1 + 8,:umn 2 * 3}
腳本2:
Clear Symbols(); //for debug
Names Default to Here(1); //namespace declaration,create variables in local scope only
ms=namespace("outer");
dt = Current Data Table();
If( Is Empty( dt ),
Try( dt = Open(), Throw( "No data table found" ) )
);
colSize = N Col( dt );
ListSize = N Items(ms:names);
For( i = 1, i < ListSize + 1, i++,
if(i > colSize, New Column( "temp" ));//create columns to accomidate list size
print(ms:names[i]);
Column(i) << Set NAME(ms:names[i]);//set column names
//col << Formula( Eval(ms:formulaList[i]) );//set column formulas
);
print(ms:formulaList);
//ms << Delete;
輸出:
COL1
2號
Con 4
柱
{Empty(),:Col1 + 8,:umn 2 * 3}
兩個主要問題,第二個數據表中的列名稱不採用新名稱 ,如果沒有註釋col << Formula break。 已嘗試過許多不同的方法,但尚未取得成功。
*編輯 - 添加列表/列大小檢查到第二個腳本
*解決了第一個問題,請參閱下面的答案。
現在的問題是,是否有特定的“類型”公式或集合公式期望它能夠運作?
謝謝!很好的JMP示例很難找到。 在我看來,腳本指南缺乏大多數實際使用它的實例。我必須檢查其中的一些功能,以便全面了解它是如何工作的,但是使用您提供的完整圖片會更容易。
以下是創建列,所有屬性,名稱,公式但沒有值的建議。
附加的腳本使用colref << get script,並使用Big Class.jmp演示腳本
Column命名問題的解決方案是“類型”問題......
腳本1中的解決方案:
ns:names = dt << Get Column Names("String");// get column names